Look up a MongoDB error by code, code name or message: what it means, why it happens, read-only checks in mongosh and safe fixes, based on MongoDB's documentation and source.
Common errors 7
11000
E11000 duplicate key errorA write would store a key that already exists in a unique index (_id or another unique field).
121
Document failed validationAn insert or update breaks the collection validator ($jsonSchema); errInfo names the failing rule.
2
BadValue: unknown operator and other invalid query valuesA query value was rejected: an unknown operator, a non-array for $in or $or, or a hint that names no index.
26
NamespaceNotFound: ns does not exist or ns not foundA command that needs an existing collection (listIndexes, dropIndexes, collMod, renameCollection) named one that does not exist.
18
Authentication failedLogin rejected: wrong user, password, authSource or mechanism; the real reason is in the server log.
13
not authorized on database to execute commandThe connection is not logged in or its user lacks a role for the command on that database.
driver
Server selection timed out (MongoServerSelectionError, ServerSelectionTimeoutError, MongoTimeoutException)The driver found no suitable server within serverSelectionTimeoutMS: nothing reachable, or no primary for the operation.
Writes & Validation 3
11000
E11000 duplicate key errorA write would store a key that already exists in a unique index (_id or another unique field).
121
Document failed validationAn insert or update breaks the collection validator ($jsonSchema); errInfo names the failing rule.
66
Performing an update on the path '_id' would modify the immutable field '_id'An update or replacement tries to change _id, which is immutable.
Queries & Aggregation 3
2
BadValue: unknown operator and other invalid query valuesA query value was rejected: an unknown operator, a non-array for $in or $or, or a hint that names no index.
9
FailedToParse: an option or stage specification is malformedA stage, expression or option such as the write concern could not be parsed: wrong argument names, types or missing fields.
292
Sort exceeded memory limit, but did not opt in to external sortingA sort, $group or $setWindowFields passed its 100 MB memory limit while disk use was not allowed.
Indexes & Collections 3
26
NamespaceNotFound: ns does not exist or ns not foundA command that needs an existing collection (listIndexes, dropIndexes, collMod, renameCollection) named one that does not exist.
48
NamespaceExists: collection already existsA create or rename targets a name already used by a collection with other options, a view or a time series collection.
85
IndexOptionsConflict: an equivalent index already exists (and 86 IndexKeySpecsConflict)createIndex conflicts with an existing index: same index with other options or name (85), or the name belongs to a different index (86).
Transactions & Concurrency 2
112
WriteConflict: please retry your operation or multi-document transactionTwo operations changed the same document at once; inside a transaction, retry the whole transaction.
251
NoSuchTransaction: transaction has been abortedThe transaction was already aborted, usually by an earlier error or the 60 second lifetime limit.
Replication & Connectivity 4
driver
Server selection timed out (MongoServerSelectionError, ServerSelectionTimeoutError, MongoTimeoutException)The driver found no suitable server within serverSelectionTimeoutMS: nothing reachable, or no primary for the operation.
10107
NotWritablePrimary: not primary (and 13435 not primary and secondaryOk=false)A write or primary-only command reached a member that is not primary; 13435 is a read on a secondary without a suitable read preference.
6
HostUnreachable: Error connecting to a member, shard or hostA MongoDB server could not reach another member, shard or config server, for example Connection refused.
89
NetworkTimeout: a network operation between MongoDB processes timed outA socket operation, connection attempt or TLS handshake between MongoDB processes ran past its time limit.
No errors match. Press Search to search full messages, or browse every error.