How to Fix MongoDB Error 79 (UnknownReplWriteConcern)
You get mongodb error 79 when a client sends a write concern that the replica set does not know. To fix this error, update your app write concern to match a valid rule in your replica set. In the database engine, code 79 has the official name UnknownReplWriteConcern. It belongs to the WriteConcernError category. When this fault happens, the primary node may still write the change. Still, the cluster cannot confirm that the requested nodes got the data. Your app gets an error back because the cl
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 79 when a client sends a write concern that the replica set does not know. To fix this error, update your app write concern to match a valid rule in your replica set.
In the database engine, code 79 has the official name UnknownReplWriteConcern. It belongs to the WriteConcernError category. When this fault happens, the primary node may still write the change. Still, the cluster cannot confirm that the requested nodes got the data. Your app gets an error back because the cluster does not know the rule.
Root causes of mongodb error 79 in replica sets
A replica set uses write concerns to know how many nodes must save a write. You can ask for a specific number of nodes or a majority. You can also use custom rule names that map to tag sets on your nodes.
The UnknownReplWriteConcern fault happens when the client requests a rule name or value that does not exist. A common cause is a typo in the client string or write request. For example, an app team might misspell the word majority in their database settings. The server looks up the misspelled word as a custom rule name, fails to find it, and returns code 79.
Another cause is a mismatch between app settings and replica set settings. An admin might remove or rename a custom write rule during a cluster change. If the app still asks for the old rule name, every write will trigger this error. It can also happen if a client asks for more nodes than the replica set has.
How to check and fix UnknownReplWriteConcern in production
Start by checking your app logs to see which write request failed. Look at the client settings and find the exact write concern string sent to the database. Compare this string against the valid rules in your replica set settings.
When you log in to check the database, use a role with minimal rights. MongoDB grants access through role-based rules that apply to a specific database down to the collection level. For example, the built-in read role grants read access to non-system collections through actions like find and listCollections. It does not allow insert, update, remove, or dropCollection actions, which keeps your data safe while you look around.
MongoDB Authentication & Authorization + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Notice that MongoDB Atlas users have different built-in roles than self-hosted users, though both use the same privilege actions. Never grant full admin rights to an app or engineer just to debug a write error. Instead, let an authorized admin inspect the replica set settings while developers check the app code.
Once you find the mismatch, you have two ways to fix it. First, if the client has a typo or an outdated rule name, fix the client settings and deploy the change. Second, if the app needs a custom rule that is missing from the cluster, an admin can add that rule to the replica set settings. Do not set the write concern to zero just to silence the error, because that skips write checks.
How to prevent write concern mismatches across teams
Write concern errors often happen when app teams and database admins do not share changes. Keep a clear list of valid write concern names in your team docs. Before an admin changes replica set tags or rules, check which apps use those rules.
You should also test database settings in a staging cluster that mirrors production. If an app uses the readWrite role to run insert, update, or remove actions in staging, a bad write concern will fail right away. Catching the typo in staging stops code 79 from hitting your live users.
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
Did my data save when mongodb error 79 happened?
Yes, in most cases the primary node still writes the data. Because code 79 is a WriteConcernError, the fault means the cluster could not confirm the write rule, not that the write itself failed.
Can a typo in the client string cause UnknownReplWriteConcern?
Yes, a typo is the most common cause of this error. If you misspell majority in your client settings, the server treats it as an unknown custom rule name and returns code 79.
Do I need the readWrite role to fix this error?
No, fixing a client typo only requires changing your app settings. Your app needs the readWrite role to insert, update, or remove data, but debugging the settings does not require extra database privileges.
Related guides
In this post