Authentication failure via API and Compass

Post screenshots of every steps that you take. The exact context of what you do often reveals the issue more that just writing that it does not work.

If you can connect with myusername and mypassword using mongosh then the server is okay and the user is okay. So it you cannot connect via Compass or API then there is something you are doing wrong. For example, do you use

in Compass or the text between the double quotes? Do you really use braces around my_hostname or not? The value of host_name must match the bindIp from your configuration file. Since you

then may be both myhostname and {myhostname} are wrong in you connection string. Because, if I remember correctly, by default mongod only listen to 127.0.0.1 or localhost. Post screenshot that shows how you connect with mongosh. Most likely you simply type mongosh so you connect to localhost:27017 rather than {myhostname}:27017.

1 Like