Firestore returns permission-denied: Missing or insufficient permissions
Uncaught Error in snapshot listener: FirebaseError: [code=permission-denied]: Missing or insufficient permissions.Short answer
Firestore rejected the request because your security rules, or App Check enforcement, did not allow it. Check four things: the rules in production mode, whether the user is signed in, whether the query matches the rule's constraints, and whether App Check is enforced without the client set up.
Fix it fast
1Find out which cause you have
Open the Rules tab of Firestore in the Firebase console and read the rule for the path you are touching. Then compare it with what the request sends: user, path, and query filters.
firebase deploy --only firestore # deploys the rules file from the project; this overwrites the rules in the console2Match what you see, then jump to its fix
- 1
Every client read and write fails, even for signed-in usersThe database is in production mode and denies clientsFix - 2
The rule contains request.auth != null and the app calls Firestore before sign-in finishesThe rule needs a signed-in user and there is noneFix - 3
A single document read works but a collection query failsThe query could return documents the rules do not allowFix - 4
The error started after you enabled enforcement for Cloud FirestoreApp Check enforcement is on but the app sends no tokenFix
- 1
What does the error look like?
Uncaught Error in snapshot listener: FirebaseError: [code=permission-denied]: Missing or insufficient permissions.FirebaseError: [code=permission-denied]: Missing or insufficient permissions.
Cause 1 of 4
The database is in production mode and denies clients
1Check
Production mode blocks all reads and writes from mobile and web clients; server libraries are not affected. The rules would read allow read, write: if false.
cat firestore.rules2Fix
Write rules that allow what the app needs, for example documents a user owns. Do not use allow read, write: if true, which lets anyone overwrite the whole database.
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /users/{userId} {
allow read, write: if request.auth != null && request.auth.uid == userId;
}
}
}3Verify
Publish the rules and repeat the request. Updates can take up to a minute to reach new queries.
firebase deploy --only firestoreConfirmed by firebase.google.com
Cause 2 of 4
The rule needs a signed-in user and there is none
1Check
Rules that check request.auth deny any request that arrives without a signed-in user.
grep -n "request.auth" firestore.rules2Fix
Wait until sign-in completes before the first Firestore call, for example by listening to auth state.
FirebaseAuth.instance.authStateChanges().listen((user) {
if (user != null) {
// safe to read or write now
}
});3Verify
Sign in, then repeat the request.
print(FirebaseAuth.instance.currentUser?.uid);Confirmed by firebase.google.com
Cause 3 of 4
The query could return documents the rules do not allow
1Check
Rules are not filters: Firestore checks the whole query against the rules, and if any possible result is not allowed the entire request fails. A rule on resource.data.author fails a query with no author filter.
grep -n "resource.data" firestore.rules2Fix
Add a where clause that matches the rule's condition.
final snap = await FirebaseFirestore.instance
.collection('stories')
.where('author', isEqualTo: FirebaseAuth.instance.currentUser!.uid)
.get();3Verify
The query returns documents without the error.
print(snap.docs.length);Confirmed by firebase.google.com
Cause 4 of 4
App Check enforcement is on but the app sends no token
1Check
With App Check enforced, requests without a valid attestation token are blocked and show the same permission-denied message.
# Firebase console: App Check, Cloud Firestore, check whether Enforce is on2Fix
Turn enforcement off while you finish setting App Check up in the client, then turn it back on and check the verified-request metrics.
# In the App Check section of the Firebase console, switch enforcement for Cloud Firestore off, finish the client setup, then switch it on again3Verify
Repeat the request while enforcement is off, then again after setup with it on.
# watch App Check metrics in the Firebase consoleConfirmed by firebase.google.com
How do I stop it coming back?
- Keep firestore.rules in the repository and deploy it from there, since a CLI deploy overwrites console edits.
- Write queries with the same filters your rules require.
- Never use allow read, write: if true outside a throwaway project.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
- SessionBirdAn omnichannel engagement suite in Flutter: campaigns, chatbot, tickets, analytics and live calling.
- WorkforceA field app, an admin console and a self-hosted Node.js server for push and reconciliation.
- Spotless LaundryAn on-demand laundry app: Flutter on a Laravel back end, with Firebase for live updates.
Related fixes
Mobile apps
Gradle cannot find com.google.firebase:firebase-analytics-ktx
Required by: project :app
Firebase moved the Kotlin extensions into the main modules and stopped releasing the -ktx modules in July 2025.
2 causes, each with a fixMobile apps
Flutter Android: Failed to load FirebaseOptions from resource
Failed to load FirebaseOptions from resource. Check that you have defined values.xml correctly.
On Android, Firebase reads its settings from a values.xml file that the Google services Gradle plugin builds from google-services.json.
4 causes, each with a fixMobile apps
Flutter: FirebaseException No AppCheckProvider installed
com.google.firebase.FirebaseException: No AppCheckProvider installed
Firebase App Check needs a provider chosen in your Dart code before other Firebase calls run.
3 causes, each with a fixMobile apps
FirebaseMessaging.getAPNSToken() returns null on iOS
FirebaseMessaging.instance.getAPNSToken() returns null
getAPNSToken() gives null when iOS has not handed the app an APNs token yet or never will.
4 causes, each with a fixMobile apps
Xcode cannot find GoogleService-Info.plist for the Runner target
error: Build input file cannot be found: '/Users/GoogleService-Info.plist' (in target 'Runner' from project 'Runner')
Xcode's project file lists GoogleService-Info.plist as an input, but nothing exists at the path it records.
3 causes, each with a fixMobile apps
Flutter: Firebase.initializeApp fails with Unable to establish connection on channel
Unable to establish connection on channel
The Dart side of firebase_core could not reach its native half.
4 causes, each with a fix