DBAtlas · Database operations atlas

43: CursorNotFound (error code 43)

MongoDB

What does it mean?

The server-side cursor no longer exists. When the client requests the next batch (getMore), the error is returned because the cursor cannot be found.

Why does it happen?

The cursor timed out (default 10 minutes of inactivity), too long a wait between batches, a server restart, or the cursor was closed explicitly.

How to fix it

Process cursor results faster; do not wait long between batches. For long-running operations, use the noCursorTimeout option carefully (mongosh: cursor.noCursorTimeout(); PyMongo: no_cursor_timeout=True) and always close the cursor; a cursor inside a session is closed at the session timeout (localLogicalSessionTimeoutMinutes, default 30 min) even with this option. For large result sets, iterate with a smaller batchSize or use range-based pagination. Restart the operation and query again.

Open in DBAtlas →

More from this engine