MongoDB E11000: duplicate key error collection

Insert/update violated a unique index (often `_id` or a unique email/slug index).

Runs locally in browser Free · No login Independently Verified 2026-11-25 v4.0.0
Identifier: MongoDB E11000: duplicate key error collection Platform: MongoDB

Interactive Diagnostic Checklist

Safe Diagnostic Command:
db.collection.getIndexes()

Technical Explanation

Insert/update violated a unique index (often `_id` or a unique email/slug index). Verified technical resolution: Inspect the offending keyPattern in the error and use `updateOne(..., { upsert: true })` where idempotent.

Worked Examples

  • Diagnostic check: db.collection.getIndexes()

Limitations & Assumptions

  • Confirm exact software version and execution layer before applying configuration changes in production.

Source References & Verification

Resource ID: err-mongo-e11000-duplicate-key · Independently verified: 2026-11-25

Related Resources