Skip to content

Firebase Firestore error

FirebaseError: Missing or insufficient permissions

Firestore’s security rules refused the read or write. The client SDKs report it as permission-denied; server libraries log 7 PERMISSION_DENIED: Missing or insufficient permissions, and the REST API returns 403 PERMISSION_DENIED. The rules are doing their job, but either they’re wrong for this request or the request doesn’t look the way the rules expect. Here’s how to find which, or hand it over at a fixed price.

Rather hand it over? App Fix Ticket: One reproducible bug in an existing mobile or web app, diagnosed and fixed.

Full refund if Simon can’t take it on once he sees your project, or if you cancel before work starts. Refund terms.

Short answer

Usually the query asks for more than the rules allow. Firestore rules are not filters: if a query could return even one document the user can’t read, the whole query fails. Add the same conditions to the query that the rule checks. Next most likely: no user is signed in yet when the request runs.

Rather not fix it yourself? App Fix Ticket starts with a fixed-price diagnosis, then a fixed price for the fix before any fix work.

The usual causes, and the fix

  1. 01

    The query doesn’t match the rule

    If the rule only allows documents where ownerId equals the user’s ID, the query must filter on ownerId too. A query for the whole collection fails even if every document in it happens to be the user’s. The same goes for limits: if the rule checks request.query.limit, the query needs a limit that passes.

    // rule: allow read: if resource.data.ownerId == request.auth.uid;
    query(collection(db, 'projects'), where('ownerId', '==', user.uid));
  2. 02

    No user is signed in yet

    Rules that check request.auth.uid fail when the request runs before sign-in finishes, or after the session ends. Start Firestore reads after the auth state listener reports a signed-in user, not on page load.

  3. 03

    The rules really do deny it

    Check the deployed rules, not the file on your laptop. If they compare request.time with a fixed date, they stop allowing anything once that date passes. Then try the exact request in the Rules Playground in the Firebase console, which tests the rules in its editor, so start from the deployed version. Unit tests against the emulator work too. After you deploy new rules, allow up to a minute for new queries and up to 10 minutes for open listeners.

  4. 04

    App Check enforcement is on

    Once App Check enforcement is on for Firestore, requests without a valid App Check token are rejected. If the error started when enforcement was turned on, set up App Check in the client, including a debug token for local testing.

Checked against the vendor’s docs on : Firebase docs: Securely query data; Firebase docs: Get started with Cloud Firestore Security Rules; Firebase docs: Quickly validate Firebase Security Rules; Firebase docs: Enable App Check enforcement.

Rather hand it over?

Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.

“Very responsive, attentive to fixing bugs, and completed the project as needed! Thank you!”
A buyer in the United States, July 2022. Shopify on Fiverr
All 127 Fiverr reviews

Related: Free Firebase rules checker · Firebase missing initial state · Firebase missing-or-invalid-nonce · Crashlytics “Missing dSYM”

Questions

More on this error

Should I set the rules to allow read, write: if true to make the error go away?

No. That lets anyone on the internet read and change every document in the database. Fix the query or the rule for the one request that fails, and keep everything else locked.

It works in the emulator but fails in production. Why?

The emulator runs the rules file listed in firebase.json, which may not match what’s deployed. Production runs whatever was last deployed. Deploy the rules you tested, then wait up to a minute before trying again.

Only one user gets the error. Why?

Their data probably breaks an assumption in the rules, such as a missing ownerId field or a role stored somewhere the rule doesn’t look. Run that user’s exact request in the Rules Playground with their user ID and the document’s data.

A Cloud Function or server gets 7 PERMISSION_DENIED. Is that the rules too?

Not if it uses the Admin SDK or a Google Cloud server library: those skip Security Rules and use the service account’s IAM roles. If the server code uses the client SDK (firebase/firestore), rules still apply, and it usually has no signed-in user. Otherwise check the service account’s Firestore role (Cloud Datastore User, for example), the project, the database ID if you use a named database, and that the Firestore API is enabled.

Can you fix it for me?

If one bug is the whole problem, the App Fix Ticket covers it: a written diagnosis first, then the fix. If the app has more going on, the Launch Check is a written check of the whole app. Each issue found is rated critical, high, medium or low, with where it is and how it was confirmed. No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way. This applies to the first 10 Launch Checks bought after October 30, 2026.

A different error?

Describe it and get a written quote

Send the error and what you were doing. You get a written scope, a fixed price and a timeline; Simon replies by email, usually within one business day.