How to Fix MongoDB Error 345 (RuntimeAuditConfigurationNotEnabled)

Published
Length
3 min read

Luis Felipe Dias

All posts

You get mongodb error 345 when you try to change audit settings at runtime without enabling runtime audit setup first. To fix it, enable runtime audit control in your server setup or update static files and restart the node. Database teams often need to adjust audit rules on live servers. When the engine blocks these live updates, it returns the RuntimeAuditConfigurationNotEnabled error code. Understanding why the server rejects this change helps you fix the issue fast. Root causes of 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 345 when you try to change audit settings at runtime without enabling runtime audit setup first. To fix it, enable runtime audit control in your server setup or update static files and restart the node.

Database teams often need to adjust audit rules on live servers. When the engine blocks these live updates, it returns the RuntimeAuditConfigurationNotEnabled error code. Understanding why the server rejects this change helps you fix the issue fast.

Root causes of mongodb error 345 in your cluster

The official name for mongodb error 345 is RuntimeAuditConfigurationNotEnabled. The database engine throws this error when an admin runs a command to update audit rules on a live node. By default, a node might lock its audit setup at startup.

If the server starts without runtime audit support turned on, it rejects live changes. This design stops users from turning off audit logs during an active breach. Even a high-level admin enforces policy on this startup lock while the node runs.

This failure often happens during compliance updates or security checks. An engineer tries to add a new filter to capture more database events. The cluster rejects the command because the startup file lacks the right audit settings.

You might also see this error when nodes in a replica set have mismatched files. One node might allow live audit changes while another node blocks them. Checking your startup files across all nodes reveals these gaps.

How to diagnose and fix the error safely

First, check if your database deployment supports runtime audit changes. Check your server startup settings to see how auditing starts. Do not grant extra roles to users just to test this error.

MongoDB grants access through role-based authorization on specific databases. A role grants privileges to run sets of actions on defined resources. Roles can grant access down to a collection level of detail.

MongoDB Authentication & Authorization + End-to-End Encryption: architecture patterns and best practices

Continue reading? Get the full guide.

Free. No spam. Unsubscribe anytime.

Still, adding more user privileges will not fix a missing startup setting. Keep most users on standard read or readWrite roles for daily work. The read role allows actions like find, listCollections, and listIndexes on non-system collections. It does not allow insert, update, remove, or dropCollection actions.

To fix error 345, update your server startup setup to allow runtime audit changes. Apply this change one node at a time in a rolling restart. Start with secondary nodes before you step down and update the primary node. This rolling method keeps your cluster online while you fix the audit rules.

Managing audit logs and data safety in production

Relying only on native database audit settings can create extra work for your team. Restarting database nodes to change audit rules takes time and careful planning. Also, self-hosted deployments and Atlas users have different built-in roles to manage.

Many teams add a central access layer in front of their databases instead. This layer logs every query and command before it reaches the database engine. You can update logging rules in one place without restarting any database nodes.

A central layer also helps protect private data in query results. For example, data masking rewrites matched fields like emails, phone numbers, and card numbers in results. Your team gets full audit logs and data safety while database nodes stay untouched.

Add command guardrails and field masking beside MongoDB

Collection roles and IP rules control who connects to MongoDB. Yet an active client or agent session can still run a pipeline that writes data or reads raw personal fields. In practice, hoop.dev sits inline in the wire protocol beside your database as a sidecar for your MongoDB. For every command an agent or human sends in production, hoop.dev decides to pass, mask, block, or escalate it for review.

Using hoop.dev MongoDB controls, guardrails refuse banned commands before they run or hold risky calls for approval, and data masking rewrites matched fields in returned documents in memory. Furthermore, hoop.dev holds SOC 2 Type II, is MIT licensed, and generates evidence for GDPR, HIPAA, and PCI DSS programs. View the project on GitHub.

Frequently asked questions

What does RuntimeAuditConfigurationNotEnabled mean in MongoDB?

It means you tried to change audit rules on a running server that blocks live audit updates. You must enable runtime audit control in the startup file or change the static file and restart.

Can I fix mongodb error 345 by granting more user roles?

No, granting extra roles will not fix this error if the server startup setup blocks runtime changes. Keep users on minimal roles like read or readWrite and fix the server startup settings instead.

Does fixing error 345 require cluster downtime?

You can avoid full cluster downtime by using a rolling restart across your replica set nodes. Update and restart secondary nodes one by one, then step down the primary node last.

The query runs. The emails stay hidden.