If you are having the error: MongoError: bad auth : Authentication failed, it must be that the password you have supplied in your connection string to connect to a particular database user in mongodb from your application is incorrect.
Mind you do not confuse your mongodb account password with the password you created for the particular user of the database you are trying to connect to – you may not have used the same password.
If you have forgotten the password you supplied for the database user, you should follow the steps below to change the password so that you can supply the right password in the mongodb connection string.
- Login to your mongodb account and click on: Database Access – follow the marker in image1 above.
- Click on Edit button for the user you want to change password for – look on the side where you have the marker in image2, that is the user – the Edit button is on the right side for this user.
- On the popup, you can see (look at the third image above) that password is already highlighted; click on the Edit Password button – see marker on the third image above – and enter the new password, scroll down and click the Update User button when you are done.
You now put the new password in the connection string and try again – the error should be gone now.