How to Fix MongoDB Error 85 (IndexOptionsConflict)
You get mongodb error 85 when you create an index that clashes with an existing one. To fix this IndexOptionsConflict error, align your app settings with the current database index or rebuild it. Database teams often see this failure during app deploys or schema updates. A release script tries to build an index that already exists with different rules. MongoDB blocks the request to protect data rules and query paths. Knowing why the conflict happens helps you fix it fast. What causes mongodb
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 get mongodb error 85 when you create an index that clashes with an existing one. To fix this IndexOptionsConflict error, align your app settings with the current database index or rebuild it.
Database teams often see this failure during app deploys or schema updates. A release script tries to build an index that already exists with different rules. MongoDB blocks the request to protect data rules and query paths. Knowing why the conflict happens helps you fix it fast.
What causes mongodb error 85 in your database
In the official spec, code 85 maps to the IndexOptionsConflict error name. The database engine raises this error when an index request matches an existing index key pattern. Still, the new request changes the options or the index name.
For example, a collection might already have a standard index on an email field. Later, a developer updates the app code to require unique values on that same email field. When the app starts, it asks the database to build the unique index. The database sees the old index on that field and stops the command.
Time-to-live settings and partial filter rules also trigger this exact conflict. If two services share one database, they might define different expiration times for the same field. Each service tries to force its own rule during startup. MongoDB rejects the second request and returns code 85 to the client.
Index name changes cause this problem too. Even if the fields and rules match, a new custom name triggers a conflict. The engine treats the name as part of the index options.
How to diagnose the conflict with safe roles
Before you change anything in production, inspect the current indexes on the target collection. You do not need full admin rights to check index definitions. MongoDB grants access through role-based authorization on defined resources down to the collection level.
Give your on-call engineer the built-in read role on the affected database. The read role grants the listIndexes and collStats actions on non-system collections. It does not permit insert, update, remove, or dropCollection actions. This keeps your production data safe while the team checks the current state.
MongoDB Authentication & Authorization + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Compare the existing index output from the database against your app migration files. Look for mismatches in uniqueness, background flags, expiration times, or custom names. Often, the database already has the right index, and the app code just has a typo.
If the database index is right, fix the app code so the options match. Once both sides declare the exact same options, MongoDB treats the create command as a safe no-op. The deploy will pass without touching any live data.
How to fix index options in production
Sometimes you really do need the new index rules in production. Because MongoDB cannot alter most index options in place, you must drop and recreate the index. This requires higher privileges than the basic read role provides.
The built-in readWrite role includes everything in the read role plus data modification rights. Specifically, the readWrite role grants both the dropIndex and createIndex privilege actions. You can scope a role to a single database to limit risk during the fix.
Dropping an index on a busy collection can hurt query speed right away. Without the index, the database must scan whole collections to answer app queries. Plan this change during low traffic hours or hide the work behind a temporary index.
Once you drop the old index, run your migration step to build the new one. Check the collection stats afterward to confirm the new options are active. Remove the temporary write role from the user account when the job is done.
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 IndexOptionsConflict mean in MongoDB?
IndexOptionsConflict is the official name for error code 85 in MongoDB. It means your command tried to create an index that shares fields with an existing index but uses different options.
Which MongoDB role can inspect indexes without changing data?
The built-in read role lets users run the listIndexes action on collections in a database. It blocks data changes and index drops, making it safe for checking production state.
Can I fix error 85 without dropping the existing index?
Yes, if the existing database index is already correct for your workload. Update your app code or migration file to match the existing index options and name.
Related guides
In this post