How to Fix MongoDB Error 385 (ConflictingServerlessOperation)
You see mongodb error 385 when two serverless tasks clash on the same resource. You fix it by spacing out admin jobs and adding retry steps in your app. The official name for this issue is ConflictingServerlessOperation in the database engine. It stops two changes from breaking your cluster state at the same time. Teams often hit this wall during busy deploys or schema updates. Knowing why the clash happens helps you keep your data safe. What causes mongodb error 385 in serverless clusters S
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 385 when two serverless tasks clash on the same resource. You fix it by spacing out admin jobs and adding retry steps in your app.
The official name for this issue is ConflictingServerlessOperation in the database engine. It stops two changes from breaking your cluster state at the same time. Teams often hit this wall during busy deploys or schema updates. Knowing why the clash happens helps you keep your data safe.
What causes mongodb error 385 in serverless clusters
Serverless databases scale up and down on their own based on load. When your app or team sends two big state changes at once, they collide. The engine blocks the second task and returns code 385 to protect data. This often happens when an index build runs during a collection drop.
Automated deploy scripts are a common source of this conflict. Two workers might try to create collections or change indexes at the exact same second. Background scaling events on the cloud host can also clash with heavy admin commands. The engine rejects the newer request so the first one can finish clean.
Role design also plays a big part in how often this error appears. In MongoDB, roles grant sets of actions on resources down to the collection level. The readWrite role lets users insert, update, remove, create collections, and drop indexes. If too many apps share this role, they can trigger conflicting schema tasks together.
How to diagnose and fix conflicting serverless operations safely
Start your check by looking at your recent database logs and deploy history. Find the exact time code 385 appeared and list all active jobs. Look for two scripts or services trying to change collections or indexes together. Once you spot the overlapping tasks, you can put them in a single line.
MongoDB Authentication & Authorization + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Update your deploy pipeline so schema changes run one by one in order. Never let multiple app nodes run index builds at startup at the same time. Move index creation and collection setup into a single pre-deploy step. Add a short pause and retry loop in your app for code 385.
Next, tighten your database roles so normal app workers cannot run schema changes. Give standard services the read role if they only need to find data. The read role allows find, listCollections, and listIndexes without allowing collection drops or writes. For apps that write data, separate everyday data updates from index management tasks.
Do not fix this error by giving every developer full cluster admin rights. Broad roles only make accidental clashes worse during live incidents. Keep write and schema privileges restricted to approved deploy jobs and checked sessions. When engineers inspect live collections, mask sensitive fields like emails, phone numbers, and card numbers so masking rewrites matched fields in results.
Check MongoDB commands and documents on the wire
MongoDB roles and SCRAM login decide who opens a session. They do not check single commands or redact sensitive fields inside returned documents. With hoop.dev, you run an open-source proxy, a sidecar for your MongoDB, inline in the MongoDB wire protocol. On every command an AI agent or engineer runs against production, hoop.dev decides to pass, mask, block, or hold it for human review.
Before a command runs, hoop.dev guardrails check its effect and refuse banned drops or writes with MongoDB error code 13, or hold risky commands for approval. On the way back, hoop.dev data masking rewrites sensitive fields in returned documents in memory, and every verdict is logged. See the open-source code on GitHub.
Frequently asked questions
What does ConflictingServerlessOperation mean in MongoDB?
It means the database stopped a request because another incompatible serverless task is running. Wait for the first operation to finish, then send your request again.
Does mongodb error 385 corrupt my collection data?
No, the database engine throws this error specifically to stop data damage. The first operation continues safely while the conflicting second request gets blocked right away.
How can I stop deploy scripts from triggering code 385?
Run all collection and index changes from one worker instead of every app instance. Wait for each schema task to finish before starting the next step.
Related guides
In this post