MongoDB Atlas Authentication Failed (bad auth)

Share
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. 1. Use a database user

    1. Open Security > Database Access
    2. Check the user exists with a role that fits (e.g. readWriteAnyDatabase)
    3. Edit the user and set a new password if unsure
    Did this fix it?
  2. 2. Percent-encode the password

    1. Encode : / ? # [ ] @ ! $ & ' ( ) * , ; = % and spaces, e.g. p@ss becomes p%40ss
    2. In Node use encodeURIComponent(password); in Python quote_plus(password)
    3. Do not encode when typing the password into mongosh's prompt
    Did this fix it?
  3. 3. Set authSource

    1. Add ?authSource=admin to the URI (or the database where the user was created)
    Did this fix it?
  4. 4. Copy a fresh string

    1. 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 us
Fixed it? Share this guide

Other MongoDB Atlas errors

All 10 MongoDB Atlas errors and fixes →