Skip to content

What does 'Missing or insufficient permissions' mean?

Short answer

Cloud Firestore Security Rules denied the read or write (error code permission-denied). Fix the rule for that path so the signed-in owner is allowed. Don't reopen the database with test-mode rules like allow read, write: if true.

Last updated 2026-11-25 · Reviewed by ProofForge

The exact error

text
FirebaseError: Missing or insufficient permissions.
(code: "permission-denied")

Why it happens

  • Test-mode rules expired (they're time-limited), so every request is now denied.
  • The request runs before Firebase Auth has signed the user in, so request.auth is null.
  • The rule checks a field (such as uid) the document doesn't have, or the query asks for documents the rule can't prove are allowed.

How to fix it

  1. Wait for onAuthStateChanged before querying.
  2. Write rules that match your data model, scoped to the owner:
  3. Make queries match the rule (for example filter by where('uid', '==', user.uid)).
js
rules_version = '2';
service cloud.firestore {
  match /databases/{database}/documents {
    match /users/{userId}/{document=**} {
      allow read, write: if request.auth != null && request.auth.uid == userId;
    }
  }
}

Check it's fixed

Use the Rules Playground in the Firebase console: allowed as the owner, denied as another user and as unauthenticated.

Check your live app

A free, read-only public-surface scan. It cannot diagnose private sessions or every cause described above.

Read-only. No writes or row contents.

FAQ

Can I switch back to test mode?

Test mode lets anyone read and overwrite your data. Firebase's docs list it as an insecure rule to avoid in production.

Why does the query fail even though each document is mine?

Rules aren't filters. The query must include constraints that guarantee every result passes the rule.

Does the Admin SDK hit this error?

No. The Admin SDK bypasses Security Rules, which is why its credentials must stay on a server.

Sources

Related

Read as Markdown · Scan methodology