My Google Maps key leaked. What do I do?
A Maps JavaScript key in your page isn't a leak by itself, because Google expects it to be public. The risk is an unrestricted key, which anyone can use for any enabled Google API on your bill. Add website (HTTP referrer) and API restrictions now. If you see abuse, regenerate the key and set quotas and budget alerts.
Last updated 2026-11-25 · Reviewed by ProofForge
Is it this key?
Format: AIza (39 characters). Public by design for the Maps JavaScript API when restricted.
Blast radius: An unrestricted key works for every API enabled in the project (Maps, Places, Geocoding, and others), billed to you.
The first 10 minutes
| When | Do | How |
|---|---|---|
| 0–3 min | Restrict | Cloud console → APIs & Services → Credentials → edit the key. Add Website restrictions (your domains) and API restrictions (only the Maps APIs you use). |
| 3–6 min | Check billing | Look at API metrics and Billing for spikes in Places, Geocoding or other APIs. |
| 6–8 min | Regenerate if abused | Regenerate or create a new key, deploy it, then delete the old one. |
| 8–10 min | Cap it | Set per-API quotas and a budget alert. Use a separate IP-restricted key for server-side calls. |
Stop the next leak
- Keep the key in a server-side env var. Never use a
VITE_,NEXT_PUBLIC_orEXPO_PUBLIC_variable or hard-code it in frontend code. - Call the provider from your backend or an edge function, and add
.env*to.gitignore. - Re-scan the live site after every deploy. Keys also leak through JS bundles, source maps and exposed
.envor.gitpaths.
Check your live app
A free, read-only public-surface scan. It cannot diagnose private sessions or every cause described above.
FAQ
My key is in page source. Do I need to hide it?
No. You can't hide a browser key. Restrict it instead.
Why did restricting break my map?
Missing referrer or API in the lists. See /errors/google-maps-key-restriction.
Same key for Gemini?
Don't reuse keys across APIs. Restrict each key to one purpose.