How to Fix MongoDB Error 36 (RemoteChangeDetected)
You see mongodb error 36 when a remote node changes state during an active task. You fix this RemoteChangeDetected error by checking cluster state and retrying the failed step. Distributed database clusters run tasks across many nodes at the same time. When one node alters data or metadata unexpectedly, the coordinating node stops its work. This safety check prevents split state and broken data across your cluster. Understanding why the remote state shifted helps your team restore normal operat
Your coding agents run with your access.
Claude Code reaches prod with a developer's credentials, and approval prompts get clicked through. hoop.dev checks every query, masks sensitive data, and holds risky changes for a human.
You see mongodb error 36 when a remote node changes state during an active task. You fix this RemoteChangeDetected error by checking cluster state and retrying the failed step.
Distributed database clusters run tasks across many nodes at the same time. When one node alters data or metadata unexpectedly, the coordinating node stops its work. This safety check prevents split state and broken data across your cluster. Understanding why the remote state shifted helps your team restore normal operations fast.
What causes mongodb error 36 in your cluster
In the official error list, code 36 carries the name RemoteChangeDetected. The database engine raises this alert when a remote host changes during a multi-node task. Sharded clusters and replica sets rely on shared state across all member nodes. A coordinator node expects remote shards or replicas to stay stable during a migration. If a remote node steps down, restarts, or updates its metadata, the coordinator halts.
Concurrent admin commands often trigger this conflict in busy production systems. Two engineers or automated scripts might run collection changes at the exact same moment. Network blips can also cause a primary node to step down mid-task. When the new primary takes over, the remote state no longer matches the original plan. The database throws code 36 to protect your collections from partial writes.
How to check and fix RemoteChangeDetected safely
Start by checking your database logs on both the coordinator and remote nodes. Look for replica set elections, shard chunk moves, or schema changes near the error time. You do not need wide admin rights just to inspect cluster state. MongoDB grants access through role-based rules that apply to a single database. You can even scope a role down to the collection level.
Give your on-call engineers a read role for initial log and state checks. The read role allows find, listCollections, listIndexes, dbStats, and collStats actions on non-system collections. It blocks insert, update, remove, and dropCollection actions so responders cannot alter live data by mistake. Note that Atlas users and self-hosted users have different built-in roles. Still, both systems build their roles from the same set of privilege actions.
Mean Time to Detect (MTTD) + MongoDB Authentication & Authorization: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Once you find the competing task, wait for the remote node to settle. Make sure no elections or background chunk moves are still running in the cluster. If a script caused the clash, pause the job before you retry your change. When a fix requires data or index updates, switch to the readWrite role briefly. The readWrite role adds insert, update, remove, createCollection, createIndex, and dropIndex actions. Retry the failed task once, and watch the logs to confirm it finishes cleanly.
How to prevent remote state conflicts in production
Most RemoteChangeDetected errors happen when too many people or tools run changes at once. Keep your human engineers and background jobs from stepping on each other. Schedule index builds and collection moves during low-traffic windows with clear team coordination. Limit who holds the readWrite role during normal daily operations.
Audit every write session so your team knows what ran before an error hit. If your team queries user tables during a check, protect sensitive fields as well. Data masking rewrites matched fields like emails, phone numbers, card numbers, and national IDs in results. Clear role limits and controlled write windows stop remote state clashes before they start.
Inspect MongoDB wire traffic in flight
Built-in MongoDB roles govern collection access at setup time. They cannot score command risk per call or mask sensitive document values on the fly. By design, hoop.dev sits inline in the MongoDB protocol next to your server as a sidecar for your MongoDB. On every production command from mongosh, drivers, or AI agents, hoop.dev decides whether to pass, mask, block, or hold it for human review.
First, hoop.dev guardrails block bad deletes, drops, and write pipelines or hold them for approval. Next, hoop.dev data masking rewrites sensitive values in returned documents in memory and logs each decision. Explore the repo on GitHub.
Frequently asked questions
What does the RemoteChangeDetected message mean in MongoDB?
RemoteChangeDetected is the official name for mongodb error 36. It means a remote node changed its state or data while another node ran a coordinated task.
Does mongodb error 36 corrupt my database collections?
No, the database raises code 36 to stop the task before corruption can happen. It aborts the operation safely so you can check the cluster and retry.
Which MongoDB role should engineers use to inspect this error?
Assign the built-in read role so engineers can run dbStats, collStats, and listIndexes safely. Only grant the readWrite role when they need to modify data or indexes.
Related guides
In this post