Firestore: The query requires an index Google Cloud / Firebase Origin: Platform & cloud OSI layer 7 · Application Last updated 4 Nov 2026

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.

Exact message you may see 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
Seen on: Google Cloud JavaScript

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

  1. Open the link in the error message to create the index
  2. Define it in firestore.indexes.json and run firebase deploy --only firestore:indexes
  3. Wait until the index status is Enabled

Detailed fix by platform

Firebase

  1. firebase deploy --only firestore:indexes

Code examples

firestore.indexes.json

json
{
  "indexes": [{
    "collectionGroup": "orders",
    "queryScope": "COLLECTION",
    "fields": [
      { "fieldPath": "userId", "order": "ASCENDING" },
      { "fieldPath": "createdAt", "order": "DESCENDING" }
    ]
  }]
}

How to diagnose

  1. Query — Filters and orderBy?
  2. Index — Exists, built?
  3. 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:

Where this error sits

Origin: Platform & cloud. Errors that are often confused with or caused by this one (click to open):

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 (Terraform)Error 403: API has no…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 (Google Cloud / Firebase)Firebase CLI: Authent…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 (Google Cloud / Firebase)Firebase Hosting: Pag…Firebase: Your project must be on the Blaze (pay-as-you-go) plan — Firebase CLI: Error: Your project my-app must be on the Blaze (pay-as-you-go) plan to complete this command. Required API cloudbuild.googleapis.com can't be enabled until the upgrade is complete (Google Cloud / Firebase)Firebase: Your projec…Firestore: DEADLINE_EXCEEDED / UNAVAILABLE — Firestore: 4 DEADLINE_EXCEEDED: Deadline exceeded / 14 UNAVAILABLE: The service is currently unavailable (Google Cloud / Firebase)Firestore: DEADLINE_E…Firestore: Document exceeds the maximum size of 1,048,576 bytes — Firestore: 3 INVALID_ARGUMENT: The value of property "data" is longer than 1048487 bytes / Document exceeds the maximum size (Google Cloud / Firebase)Firestore: Document e…Google provider: could not find default credentials — Terraform: Error: Attempted to load application default credentials since neither `credentials` nor `access_token` was set in the provider block. No credentials loaded (Terraform)Google provider: coul…messaging/registration-token-not-registered — Firebase Cloud Messaging: messaging/registration-token-not-registered — The provided registration token is not registered (Google Cloud / Firebase)messaging/registratio…Firestore…

Explore the map of this error Full error map →

🧠 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.