mongorestore: failed to restore (duplicate key / BSON / version) MongoDB Origin: Data Last updated 5 Nov 2026

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.

Exact message you may see 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
Seen on: MongoDB Linux

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

  1. mongorestore --drop --gzip --archive=dump.gz
  2. Use matching or newer tools
  3. Grant the restore role to the user

Detailed fix by platform

Linux

  1. mongorestore --uri "mongodb://user:pass@host/?authSource=admin" --drop --gzip --archive=backup.gz

How to diagnose

  1. Existing — Docs already there?
  2. Version — Tool vs server?
  3. 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:

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…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…createIndex failed: unique index with duplicates — MongoServerError: Index build failed: E11000 duplicate key error collection: db.users index: email_1 dup key (MongoDB)createIndex failed: u…E11000 duplicate key — MongoServerError: E11000 duplicate key error collection: db.users index: email_1 dup key (Node.js)E11000 duplicate keyMongoDB Atlas: connection timed out — IP not whitelisted — MongoServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted (MongoDB)MongoDB Atlas: connec…mongodump: Failed: not authorized / authentication failed — mongodump: Failed: error getting database collections: not authorized on db to execute command { listCollections } (MongoDB)mongodump: Failed: no…Sort/Group exceeded memory limit of 100 MB (allowDiskUse) — MongoServerError: Exceeded memory limit for $group, but didn't allow external sort. Pass allowDiskUse:true to opt in (MongoDB)Sort/Group exceeded m…mongorest…

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.