Error codes

The error codes you will see most, with their codeName and when they appear.

The codes and codeName values are MongoDB's. The error document carries ok: 0, errmsg, code, codeName, the error's own fields and errorLabels when there are labels.

CodecodeNameWhen it appears
2BadValueAn option or a value is not valid.
9FailedToParseThe command is malformed.
11UserNotFoundThe user does not exist.
13UnauthorizedThe user lacks the privilege the command needs.
14TypeMismatchA field of the command has the wrong BSON type.
18AuthenticationFailedAuthentication failed.
20IllegalOperationThe target does not allow the operation, such as writing to the local database.
22InvalidBSONThe BSON is not valid, for example with text that is not UTF-8.
26NamespaceNotFoundThe collection does not exist where it is required.
27IndexNotFoundA $text query has no text index.
43CursorNotFoundThe cursor expired, was closed or belongs to another node.
48NamespaceExistsThe collection already exists.
50MaxTimeMSExpiredThe maxTimeMS time limit ran out.
59CommandNotFoundThe command does not exist, including deprecated ones that are not implemented.
72InvalidOptionsA combination of options is not valid.
112WriteConflictAnother write touched the same document; it carries the TransientTransactionError label.
121DocumentValidationFailureThe document does not meet the collection validator.
225TransactionTooOldThe txnNumber is lower than the last one seen.
239SnapshotTooOldThe read timestamp is older than the history that is kept.
251NoSuchTransactionThe transaction does not exist, was aborted or expired.
257TransactionTooLargeThe state of the transaction does not fit in its coordinator's memory.
263OperationNotSupportedInTransactionThe operation is not allowed inside a transaction.
292QueryExceededMemoryLimitNoDiskUseAllowedA stage needs more memory and has no allowDiskUse.
10334BSONObjectTooLargeThe document is over the maximum BSON size.
11000DuplicateKeyA unique index already has that value.

See also