mongodump: Failed: not authorized / authentication failed MongoDB Origin: Data Last updated 5 Nov 2026

mongodump: Failed: error getting database collections: not authorized on db to execute command { listCollections }

mongodump connected but the user isn't allowed to read the data, or authentication didn't happen.

Exact message you may see mongodump: Failed: error getting database collections: not authorized on db to execute commandFailed: can't create session: could not connect to server: server selection errormongodump Authentication failederror getting database collections: not authorized
Seen on: MongoDB Linux

Meaning

Provide credentials and the right authSource: --uri "mongodb://user:pass@host/db?authSource=admin". The user needs read (or backup) role on the databases. For Atlas use the connection string with a user that has readAnyDatabase or specific read roles.

Common causes

  • No credentials passed
  • Missing authSource
  • User lacks backup/read role
  • Special characters in the password not URL-encoded
  • Connecting to the wrong host/port

⚡ Quick fix

  1. Use --uri with credentials and authSource
  2. Grant backup role: db.grantRolesToUser("u",[{role:"backup",db:"admin"}])
  3. URL-encode special characters

Detailed fix by platform

Linux

  1. mongodump --uri "mongodb://backup:pass@host:27017/?authSource=admin" --gzip --archive=dump.gz

How to diagnose

  1. Credentials — Passed?
  2. Role — backup/read?
  3. authSource — admin?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Data. Errors that are often confused with or caused by this one (click to open):

Atlas: bad auth: Authentication failed — MongoServerError: bad auth : Authentication failed. (Atlas user / special characters in password) (MongoDB)Atlas: bad auth: Auth…Authentication token manipulation error — passwd: Authentication token manipulation error (Linux)Authentication token …BSONObj size is invalid / exceeds maximum document size (16MB) — MongoServerError: BSONObj size: 17825792 (0x1100000) is invalid. Size must be between 0 and 16793600(16MB) (MongoDB)BSONObj size is inval…denied — denied: requested access to the resource is denied (docker push) (Docker)denieddocker-credential-desktop — error getting credentials - err: exec: "docker-credential-desktop": executable file not found in $PATH (Docker)docker-credential-des…ECR token expired — denied: Your authorization token has expired. Reauthenticate and try again. (Amazon ECR) (AWS)ECR token expiredError saving credentials — Error saving credentials: error storing credentials - err: exit status 1 (Docker)Error saving credenti…incorrect username or password — Error response from daemon: Get "https://registry-1.docker.io/v2/": unauthorized: incorrect username or password (Docker)incorrect username or…mongodump…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.