MongoDB Atlas Authentication Failed (bad auth)
Workaround available All drivers, Compass, mongosh Updated November 13, 2026Based on 3 user reportsHow we research
Quick answer
'Authentication failed' means Atlas rejected the database user credentials. Check you used the database user (not your Atlas login), the right authSource, and URL-encode special characters in the password.
Most likely fix: Use a database user
How to fix it
Try these in order — the most common fix is first.
1. Use a database user
- Open Security > Database Access
- Check the user exists with a role that fits (e.g. readWriteAnyDatabase)
- Edit the user and set a new password if unsure
Did this fix it?2. Percent-encode the password
- Encode : / ? # [ ] @ ! $ & ' ( ) * , ; = % and spaces, e.g. p@ss becomes p%40ss
- In Node use encodeURIComponent(password); in Python quote_plus(password)
- Do not encode when typing the password into mongosh's prompt
Did this fix it?3. Set authSource
- Add ?authSource=admin to the URI (or the database where the user was created)
Did this fix it?4. Copy a fresh string
- Click Connect on the cluster, choose Drivers, and replace <password> with your database user's password (without the angle brackets)
Did this fix it?
Symptoms
MongoServerError: bad auth : Authentication failed (code 8000), or 'Authentication failed' in Compass, mongosh or your driver.
Why it happens
- Using the Atlas account email/password instead of a database user
- Wrong password or user for this project
- Unencoded special characters (@ : / ? # etc.) in the URI
- Wrong authSource
- User was edited and not yet applied or was deleted
This guide also covers
- mongodb atlas authentication failed
- mongoservererror bad auth
- mongodb atlas bad auth authentication failed
- mongodb password special characters
Still not working?
If MongoDB Atlas keeps failing, you're not alone. See every MongoDB Atlas problem users report or the alternatives people switch to.
Have an app idea? Our small team builds any software: web and mobile apps, games, desktop, AI tools. Price agreed together.
Talk to usOther MongoDB Atlas errors
- MongoDB Atlas Connection Timed Out (IP Not Whitelisted)
- MongoServerSelectionError: Fix for MongoDB Atlas
- MongoDB querySrv ENOTFOUND / ECONNREFUSED Error
- MongoDB Atlas Free Tier (M0) Limits and Throttling
- MongoDB Atlas Cluster Paused (Resume or Auto-Pause)
- MongoDB Atlas Unexpected Bill: Why It's So High
- MongoDB Atlas Too Many Connections Error
- MongoDB Atlas AWS VPC Peering Not Connecting