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.
| Code | codeName | When it appears |
|---|---|---|
| 2 | BadValue | An option or a value is not valid. |
| 9 | FailedToParse | The command is malformed. |
| 11 | UserNotFound | The user does not exist. |
| 13 | Unauthorized | The user lacks the privilege the command needs. |
| 14 | TypeMismatch | A field of the command has the wrong BSON type. |
| 18 | AuthenticationFailed | Authentication failed. |
| 20 | IllegalOperation | The target does not allow the operation, such as writing to the local database. |
| 22 | InvalidBSON | The BSON is not valid, for example with text that is not UTF-8. |
| 26 | NamespaceNotFound | The collection does not exist where it is required. |
| 27 | IndexNotFound | A $text query has no text index. |
| 43 | CursorNotFound | The cursor expired, was closed or belongs to another node. |
| 48 | NamespaceExists | The collection already exists. |
| 50 | MaxTimeMSExpired | The maxTimeMS time limit ran out. |
| 59 | CommandNotFound | The command does not exist, including deprecated ones that are not implemented. |
| 72 | InvalidOptions | A combination of options is not valid. |
| 112 | WriteConflict | Another write touched the same document; it carries the TransientTransactionError label. |
| 121 | DocumentValidationFailure | The document does not meet the collection validator. |
| 225 | TransactionTooOld | The txnNumber is lower than the last one seen. |
| 239 | SnapshotTooOld | The read timestamp is older than the history that is kept. |
| 251 | NoSuchTransaction | The transaction does not exist, was aborted or expired. |
| 257 | TransactionTooLarge | The state of the transaction does not fit in its coordinator's memory. |
| 263 | OperationNotSupportedInTransaction | The operation is not allowed inside a transaction. |
| 292 | QueryExceededMemoryLimitNoDiskUseAllowed | A stage needs more memory and has no allowDiskUse. |
| 10334 | BSONObjectTooLarge | The document is over the maximum BSON size. |
| 11000 | DuplicateKey | A unique index already has that value. |
See also
- Multi-document transactions, with the transient errors.
- Differences with MongoDB