How to Fix MongoDB Error 224 (QueryFeatureNotAllowed)
You get mongodb error 224 when a query uses a blocked database feature. To fix this QueryFeatureNotAllowed failure, rewrite the query or update server rules. This error stops queries that break cluster limits or role rules. Teams see it during version upgrades, migrations, or strict database sessions. Fixing the issue takes a clear look at the query and server state. What causes mongodb error 224 in your database MongoDB returns code 224 with the name QueryFeatureNotAllowed when an operation
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 224 when a query uses a blocked database feature. To fix this QueryFeatureNotAllowed failure, rewrite the query or update server rules.
This error stops queries that break cluster limits or role rules. Teams see it during version upgrades, migrations, or strict database sessions. Fixing the issue takes a clear look at the query and server state.
What causes mongodb error 224 in your database
MongoDB returns code 224 with the name QueryFeatureNotAllowed when an operation is blocked. Several conditions in the engine, cluster, or client setup can trigger this code.
First, the cluster might run in a restricted state during an upgrade. When nodes run mixed versions, the engine blocks newer query features until finishes. Second, server settings often disable specific query operators for security reasons. Admins turn off server-side script execution to stop unsafe queries from running.
Third, special collection types place strict limits on query features. Views, time-series collections, and encrypted fields only support a subset of operators. When a client sends an unsupported stage, the engine rejects the request. Finally, user roles might lack the rights needed for certain query actions. MongoDB grants access through roles that define allowed actions on specific resources. A role applies to its defined database down to the collection level.
How to diagnose and fix QueryFeatureNotAllowed safely
Start by reading the full error message in your app or database logs. The server message usually names the exact stage or operator that failed. Check which collection the query targets and whether it is a view.
Next, review the query structure with your team. If the query uses custom scripts, replace them with standard aggregation stages. Standard operators run faster and do not need relaxed server security rules. Never turn off safety checks in production just to pass one query.
MongoDB Authentication & Authorization + End-to-End Encryption: architecture patterns and best practices
Continue reading? Get the full guide.
Free. No spam. Unsubscribe anytime.
Then, check if the user role has the right actions for the query. The built-in read role grants read access to all non-system collections. It allows actions like find, listCollections, listIndexes, dbStats, collStats, and changeStream. It does not allow insert, update, remove, or dropCollection actions. The readWrite role adds data changes like insert, update, remove, and index creation. Atlas users and self-hosted users have different built-in roles built from privilege actions.
Give the user or app only the minimum role needed for the job. Grant access down to the collection level instead of the whole cluster.
Preventing query errors in production
Most query errors happen when ad-hoc queries reach production without a review. Engineers running manual checks might use blocked stages or ask for broad roles. You can stop these issues by adding clear controls before queries run.
Keep production users on strict read roles for daily debugging work. Review ad-hoc queries in a staging setup that matches your production rules. Add data masking to rewrite emails, phone numbers, and card numbers in results. This lets engineers debug query failures safely while keeping sensitive fields protected.
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 QueryFeatureNotAllowed mean in MongoDB?
QueryFeatureNotAllowed is the official name for error code 224 in MongoDB. It means the server blocked a query feature due to rules or limits.
Can missing role permissions cause query failures?
Yes, roles control which actions a user can run on a collection. If a query needs an action outside the read role, the server blocks it.
Should I enable server-side scripting to fix error 224?
No, enabling server-side scripts in production creates security risks for your data. Instead, rewrite the query to use standard aggregation operators that are safe.
Related guides
In this post