Firebase: auth/invalid-api-key — Your API key is invalid, please check you have copied it correctly
The web config's apiKey is wrong, missing or restricted.
Firebase: Error (auth/invalid-api-key).Your API key is invalid, please check you have copied it correctlyAPI key not valid. Please pass a valid API key.INVALID_API_KEY Firebase Meaning
Copy the config from Project settings → Your apps, make sure environment variables are actually loaded at build time (NEXT_PUBLIC_, VITE_), and in Google Cloud check API key restrictions (HTTP referrers, API restrictions allowing Identity Toolkit).
Common causes
- apiKey undefined (env var not loaded)
- Key from another project
- API key restrictions blocking the origin
- Typo/copy error
- Wrong app config used per environment
⚡ Quick fix
- Re-copy the Firebase config
- Verify env vars at build time
- Check key restrictions in Cloud Console → Credentials
Detailed fix by platform
JavaScript
console.log(import.meta.env.VITE_FIREBASE_API_KEY) // must not be undefined
How to diagnose
- apiKey — Defined?
- Project — Right?
- Restrictions — Allow origin/API?
🔧 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
- API has not been used in project before or it is disabled Google Cloud: 403 SERVICE_DISABLED — Cloud Resource Manager API has not been used in project 123456 before or it is disabled. Enable it by visiting
- App Check Firebase App Check: requests rejected (403 / app-check-token-is-invalid / attestation failed)
- auth/account-exists-with-different-credential Firebase Auth: account exists with a different credential (same email, other provider)
Most viewed in Google Cloud / Firebase
- Missing or insufficient permissions Firestore: FirebaseError: [code=permission-denied]: Missing or insufficient permissions
- 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
- 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 18 Nov 2026