# What does 'RefererNotAllowedMapError' or 'This API key is not authorized to use this service or API' mean?

**Short answer:** Your Google Maps API key has restrictions, and this request doesn't match them. Either your site's URL isn't in the key's allowed HTTP referrers (`RefererNotAllowedMapError`), or the API you're calling isn't in the key's API restrictions (`ApiTargetBlockedMapError`). Add the exact referrer or API. Don't remove restrictions, because Maps keys ship in public code and unrestricted ones get abused.

*Last updated 2026-11-25 · Reviewed by ProofForge*

## The exact error

```text
Google Maps JavaScript API error: RefererNotAllowedMapError
The current URL loading the Maps JavaScript API has not been added to the list of allowed referrers.

ApiTargetBlockedMapError: This API key is not authorized to use this service or API.
```

## Why it happens

- Production domain (or www) missing from the key's website restrictions.
- You started calling a new API (Places, Geocoding) that isn't in the key's API list.
- The API isn't enabled for the project (`ApiNotActivatedMapError`).

## How to fix it

1. In Google Cloud console → APIs & Services → Credentials, edit the key.
2. Under Application restrictions → Websites, add `https://example.com/*` and `https://www.example.com/*`.
3. Under API restrictions, add only the APIs the page uses.
4. Use a separate, IP-restricted key for server-side web services like Geocoding.

```text
Website restrictions:
  https://example.com/*
  https://www.example.com/*
API restrictions:
  Maps JavaScript API
  Places API
```

## Check it's fixed

The map loads on your domain, and the same key fails from another origin.

> **Scan box (use the site's ScanBox component):** Check whether your live app has this problem. Paste your URL for a free outside-in scan covering exposed keys, open database rules, CORS and security headers. [Scan my app free →](https://proofforge.live/#scan)

## FAQ

### Is it OK that my Maps key is visible in the page?
Yes for the Maps JavaScript API, as long as it's restricted to your referrers and APIs.

### Why does it take a while to work?
Key restriction changes can take a few minutes to apply.

### My key leaked and has no restrictions. What now?
Add restrictions, or regenerate it, and check billing. See /leaked-keys/google-maps.

## Sources

- [Google Maps JavaScript API: Error messages](https://developers.google.com/maps/documentation/javascript/error-messages)
- [Google Maps Platform security guidance](https://developers.google.com/maps/api-security-best-practices)

## Related

- [Google Maps key leaked: first 10 minutes](/leaked-keys/google-maps)
- [Exposed API key checker](/tools/exposed-api-key-checker)
- [Fix: secrets in VITE_ / NEXT_PUBLIC_ vars](/fix/vite-env-secrets)
- [All errors](/errors)
