mongorestore: Failed: db.coll: error restoring from dump: E11000 duplicate key error / unsupported BSON version
mongorestore couldn't load some documents — they already exist, indexes conflict, or the dump/server versions don't match.
mongorestore: Failed: error restoring from dumpFailed: db.coll: error restoring from dump: E11000 duplicate key errormongorestore: error running create command: Unsupported featureFailed: restore error: error running create commandmongorestore Failed Meaning
Use --drop to replace existing collections, --nsInclude/--nsExclude to restrict, and keep tool and server versions compatible (restore with an equal or newer mongorestore). Duplicate-key errors mean documents already exist; index failures happen when unique indexes conflict with data.
Common causes
- Target already has the documents (no --drop)
- Unique index conflicts
- Tools older than the server version
- Dump taken with different
--gzip/archive options - Insufficient privileges (restore role)
⚡ Quick fix
mongorestore --drop --gzip --archive=dump.gz- Use matching or newer tools
- Grant the
restorerole to the user
Detailed fix by platform
Linux
mongorestore --uri "mongodb://user:pass@host/?authSource=admin" --drop --gzip --archive=backup.gz
How to diagnose
- Existing — Docs already there?
- Version — Tool vs server?
- Role — restore?
🔧 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)
- BSONObj size is invalid / exceeds maximum document size (16MB) MongoServerError: BSONObj size: 17825792 (0x1100000) is invalid. Size must be between 0 and 16793600(16MB)
- createIndex failed: unique index with duplicates MongoServerError: Index build failed: E11000 duplicate key error collection: db.users index: email_1 dup key
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