Mongodb + Atlas: 'bad auth Authentication failed.', code: 8000,

I had same problem, in that connection string it was written "mongodb+srv://<username>:<password>@cluster0.4h226.mongodb.n..." and you are supposed to enter username and password in that string.

  1. suppose my username is "user" and password is password, we are supposed to write "mongodb+srv://user:[email protected]...", without "<" and ">";

  2. If there are any special characters in your password, replace them with their ascii code preceded by the % sign. For example, # would be %35.


I just had this problem knowing that I was using the correct username, password and DBname.

I tried to change the password for the db user to double check, but it still didn't work.

I then instead created a new user, gave the user admin role, set the password etc, and then used that new user and password (same dbname) for the connection and it worked.

I don't know exactly what the issue was, but hoping it can help some of you save some time :)

Good luck!

enter image description here