MongoDB Error Codes
Numeric error codes returned in the MongoDB server response document under the code field. Client drivers also surface these via exception types. Codes are stable across MongoDB versions.
References
51 codes
-
1InternalError -
2BadValue -
4NoSuchKey -
9FailedToParse -
13Unauthorized -
14TypeMismatch -
16InvalidLength -
17ProtocolError -
18AuthenticationFailed -
20IllegalOperation -
22InvalidBSON -
24LockTimeout -
26NamespaceNotFound -
27IndexNotFound -
40ConflictingUpdateOperators -
43CursorNotFound -
46CursorKilled -
50MaxTimeMSExpired -
51MaxTimeMSExpiredError -
59CommandNotFound -
61ShardKeyNotFound -
66ImmutableField -
67CannotCreateIndex -
68IndexAlreadyExists -
72InvalidIdField -
73InvalidDBRef -
85IndexOptionsConflict -
86IndexKeySpecsConflict -
89NetworkInterfaceExceededTimeLimit -
91ShutdownInProgress -
96InterruptedAtShutdown -
112WriteConflict -
115CommandFailed -
120NotPrimaryNoSecondaryOk -
121DocumentValidationFailure -
125CommandNotSupported -
126NamespaceExists -
136ExceededTimeLimit -
148SnapshotTooOld -
166TransactionTooLarge -
167UnknownTransactionCommitResult -
189ElectionInProgress -
190IncompleteTransactionHistory -
197NoSuchTransaction -
200QueryPlanKilled -
251NoSuchTransaction -
11000DuplicateKey -
11600InterruptedDueToReplStateChange -
13297DatabaseDifferCase -
13388StaleConfig -
16755Location16755