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.
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 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/readrole - Special characters in the password not URL-encoded
- Connecting to the wrong host/port
⚡ Quick fix
- Use
--uriwith credentials andauthSource - Grant
backuprole:db.grantRolesToUser("u",[{role:"backup",db:"admin"}]) - URL-encode special characters
Detailed fix by platform
Linux
mongodump --uri "mongodb://backup:pass@host:27017/?authSource=admin" --gzip --archive=dump.gz
How to diagnose
- Credentials — Passed?
- Role — backup/read?
- 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:
Similar errors
- Atlas: bad auth: Authentication failed MongoServerError: bad auth : Authentication failed. (Atlas user / special characters in password)
- Authentication token manipulation error passwd: Authentication token manipulation error
- BSONObj size is invalid / exceeds maximum document size (16MB) MongoServerError: BSONObj size: 17825792 (0x1100000) is invalid. Size must be between 0 and 16793600(16MB)
Most viewed in MongoDB
- MongoParseError MongoDB: MongoParseError: Invalid scheme, expected connection string to start with "mongodb://" or "mongodb+srv://"
- Document failed validation MongoDB: MongoServerError: Document failed validation (code 121)
- bad auth : Authentication failed MongoDB: MongoServerError: bad auth : Authentication failed (code 8000 / 18)
Other ways to find it
Where this error sits
Origin: Data. Errors that are often confused with or caused by this one (click to open):
🧠 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.
Report a correction or suggest an improvement
Last updated 5 Nov 2026