MongoDB Errors

Browse server error codes and driver error classes with explanations and diagnostic guidance.

PyMongoAutoReconnect
Raised when a connection to the database is lost and an attempt to auto-reconnect will be made. Application code should handle this and retry the operation.
general
PyMongoBulkWriteError
Raised when one or more errors occur during a bulk write operation
write
PyMongoConfigurationError
Raised when a configuration error is detected (e.g. malformed URI, invalid option)
configuration
PyMongoConnectionFailure
A connection to the MongoDB database cannot be made or was lost
connectivitynetworking
PyMongoCursorNotFound
Raised when a cursor used in a getMore operation is not found on the server (cursor may have timed out)
cursor
PyMongoDocumentTooLarge
Raised when a document exceeds the maximum BSON document size (16MB)
general
PyMongoDuplicateKeyError
Raised when a write attempts to create a duplicate value in a unique index (server error code 11000)
general
PyMongoEncryptionError
Raised when client-side field level encryption or auto-encryption fails
security
PyMongoExecutionTimeout
Raised when an operation exceeds the server-side maxTimeMS limit
timeout
PyMongoInvalidDocument
Raised when a document cannot be encoded to BSON (e.g. unsupported type, circular reference)
configuration
PyMongoInvalidOperation
Raised when an invalid operation is attempted (e.g. using a closed client, modifying a cursor after execution)
configuration
PyMongoInvalidURI
Raised when the MongoDB connection URI is malformed or contains invalid options
configuration
PyMongoNetworkTimeout
An operation on an open connection exceeded socketTimeoutMS. The connection is closed.
timeoutconnectivity
PyMongoOperationFailure
Raised when a database operation fails. Includes the server error code and details.
general
PyMongoPyMongoError
Base class for all PyMongo exceptions
general
PyMongoServerSelectionTimeoutError
No MongoDB server matching the selection criteria was found within serverSelectionTimeoutMS
connectivitytopologytimeout
PyMongoWriteConcernError
Raised when a write operation succeeds but the write concern was not satisfied
write
PyMongoWriteError
Base class for errors from individual write operations (inserts, updates, deletes)
write