CursorNotFound: cursor id not found MongoDB Origin: Data OSI layer 7 · Application Last updated 5 Nov 2026

MongoServerError: cursor id 1234567890 not found (CursorNotFound)

A cursor you were iterating timed out or was killed on the server, so the next batch fails.

Exact message you may see cursor id not foundMongoServerError: cursor id 1234567890 not foundCursorNotFound: cursor id not found on serverMongoCursorNotFoundError: Cursor not found (id:getMore command failed: Cursor not found
Seen on: MongoDB Node.js

Meaning

Server cursors time out after 10 minutes of inactivity. Slow per-document processing between batches triggers this. Fix by processing faster, using smaller batches (batchSize), noCursorTimeout with explicit close (careful), paginating with _id > lastId, or storing results then processing.

Common causes

  • Processing each doc slowly while iterating
  • Cursor idle for over 10 minutes
  • Server restarted/failed over
  • Cursor killed manually
  • Using a huge find() without pagination

⚡ Quick fix

  1. Paginate: find({_id: {$gt: last}}).sort({_id:1}).limit(1000)
  2. Lower batchSize or process faster
  3. noCursorTimeout: true and always close the cursor

Detailed fix by platform

mongosh

  1. db.coll.find().batchSize(500) or cursor.noCursorTimeout() with cursor.close()

How to diagnose

  1. Idle — Time between batches?
  2. Failover — Occurred?
  3. Pagination — Used?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Data. Errors that are often confused with or caused by this one (click to open):

Atlas: bad auth: Authentication failed — MongoServerError: bad auth : Authentication failed. (Atlas user / special characters in password) (MongoDB)Atlas: bad auth: Auth…BSONObj size is invalid / exceeds maximum document size (16MB) — MongoServerError: BSONObj size: 17825792 (0x1100000) is invalid. Size must be between 0 and 16793600(16MB) (MongoDB)BSONObj size is inval…Can't connect from another host (bindIp 127.0.0.1) — MongoDB: connection refused / timed out from a remote host — mongod bindIp defaults to 127.0.0.1 (MongoDB)Can't connect from an…MongoDB Atlas: connection timed out — IP not whitelisted — MongoServerSelectionError: Could not connect to any servers in your MongoDB Atlas cluster. One common reason is that you're trying to access the database from an IP that isn't whitelisted (MongoDB)MongoDB Atlas: connec…MongoServerSelectionError — MongooseServerSelectionError: connect ECONNREFUSED 127.0.0.1:27017 (Node.js)MongoServerSelectionE…No primary found in replica set / ReplicaSetNoPrimary — MongoServerSelectionError: Server selection timed out after 30000 ms — topology type ReplicaSetNoPrimary (MongoDB)No primary found in r…Query failed: $or / $in / projection errors (BadValue) — MongoServerError: Unknown modifier / unknown top level operator: $foo / Cannot use $in with a non-array (MongoDB)Query failed: $or / $…Sort/Group exceeded memory limit of 100 MB (allowDiskUse) — MongoServerError: Exceeded memory limit for $group, but didn't allow external sort. Pass allowDiskUse:true to opt in (MongoDB)Sort/Group exceeded m…CursorNot…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.