Firestore: 9 FAILED_PRECONDITION: The query requires an index. You can create it here: https://console.firebase.google.com/...
Your Firestore query combines filters/orderings that need a composite index that does not exist yet.
The query requires an index. You can create it hereFAILED_PRECONDITION: The query requires an index9 FAILED_PRECONDITION: The query requires an indexfirestore index required console.firebase.google.comCloud Firestore requires an index composite Meaning
Click the link in the error (it pre-fills the index) or add it to firestore.indexes.json and deploy. Queries with equality on one field and range/order on another, or multiple orderBy, need composite indexes. Index builds take a few minutes.
Common causes
- Composite query without a composite index
- Range filter on one field with orderBy on another
- Index still building
- Index deleted or collection group scope wrong
- Query changed after deploy
⚡ Quick fix
- Open the link in the error message to create the index
- Define it in
firestore.indexes.jsonand runfirebase deploy --only firestore:indexes - Wait until the index status is Enabled
Detailed fix by platform
Firebase
firebase deploy --only firestore:indexes
Code examples
firestore.indexes.json
{
"indexes": [{
"collectionGroup": "orders",
"queryScope": "COLLECTION",
"fields": [
{ "fieldPath": "userId", "order": "ASCENDING" },
{ "fieldPath": "createdAt", "order": "DESCENDING" }
]
}]
}How to diagnose
- Query — Filters and orderBy?
- Index — Exists, built?
- Scope — Collection vs group?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- Error 403: API has not been used in project (Terraform) Terraform: Error: Error creating Network: googleapi: Error 403: Compute Engine API has not been used in project 123 before or it is disabled
- Firebase CLI: Authentication Error: Your credentials are no longer valid Firebase CLI: Error: Authentication Error: Your credentials are no longer valid. Please run firebase login --reauth
- Firebase Hosting: Page Not Found on refresh (SPA routes) Firebase Hosting: Page Not Found — This file does not exist and there was no 404.html or index.html found in the document root
Most viewed in Google Cloud / Firebase
- Container failed to start Cloud Run: The user-provided container failed to start and listen on the port defined provided by the PORT=8080 environment variable
- Could not load the default credentials Google Cloud: Error: Could not load the default credentials. Browse to https://cloud.google.com/docs/authentication/getting-started
- 409: The resource already exists Compute Engine: ERROR: (gcloud.compute.instances.create) Could not fetch resource: The resource 'projects/p/zones/z/instances/vm-1' already exists
Other ways to find it
Where this error sits
Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
💬 What worked for others
No tips yet — did something else fix this for you?
Share what worked for you
Tips are checked by an editor before they appear. Links are removed.
Report a correction or suggest an improvement
Last updated 4 Nov 2026