Knowledge base / Network & CSP

Google Maps works for me but not for visitors

A customer says the map is broken. You open the page and it's fine. Either something between that visitor and Google is stopping the Maps requests, or they are getting a different version of your page from the one you see. Reproducing it is most of the work.

How to tell this is your problem

  • Customers report a broken map that you can't reproduce on your own machine.
  • Reports cluster around one company, one country, one browser or one time of day.
  • Your logged-in or cached session always works.
  • When a customer sends a screenshot of their console, the Maps requests show as blocked or failed rather than returning a Maps error code.

A visitor with a blocking extension or filtering network often sees something like this:

GET https://maps.googleapis.com/maps/api/js?key=… net::ERR_BLOCKED_BY_CLIENT
Uncaught ReferenceError: google is not defined

ERR_BLOCKED_BY_CLIENT means something in the visitor's own browser cancelled the request, usually an extension. The second line is your own map code failing because the API never arrived.

Why it happens

Ranked roughly by how often each turns out to be the cause:

  • You see a different page. Logged-in WordPress users usually bypass the page cache. Visitors get a cached copy that may still hold an old key or an old loader. Fix the key and forget to clear the cache, and only you see the fix.
  • A consent tool. You accepted cookies months ago. New visitors who decline, or whose banner fails to load, never get the map.
  • Ad-blockers and privacy extensions. Some filter lists and privacy tools block requests to Google hosts, including Maps. Some privacy tools also strip or change the Referer header, which can make a correctly restricted key fail for that visitor with RefererNotAllowedMapError.
  • Corporate networks. Firewalls, proxies and DNS filters in offices, schools and public Wi-Fi can block Google domains or break HTTPS inspection.
  • Regional blocks. Google services are unavailable or unreliable in some countries, so visitors there may never get a map.
  • A different hostname. Visitors arrive on www. while you use the bare domain, or on an old domain that still serves the site. If the key's website restrictions don't list that hostname, the map fails only there.
  • Quota running out later in the day. If you check in the morning and customers complain in the afternoon, a daily quota may be running out. See tracing OverQuotaMapError.

Reproduce it, step by step

  1. 01Ask the customer for the exact URL, browser and device, and whether they're on a work network. If they can, ask for a screenshot of the console.
  2. 02Open the URL in a private window, logged out. That bypasses your login and most of your cache exemptions.
  3. 03Decline the cookie banner, then reload. Then accept it and reload. Note what you see each time.
  4. 04Try the exact hostname they used, with and without www..
  5. 05Install a common ad-blocker in a separate browser profile and load the page with it on.
  6. 06Switch your phone off Wi-Fi and load the page over mobile data, to rule out your own DNS or proxy.
  7. 07Run a scan of the page. It loads the page from a clean session on a server outside your network and records console errors and any Maps requests that fail at the network layer.

If the scan is clean and your private window is clean, the problem is on the visitor's side: their extension, network or country. If the scan shows an error your browser doesn't, you're seeing a cached or logged-in version of the page.

What to fix

If it's your cache

Clear the page cache, any server-level cache and your CDN after every change to a key or map setting. Then check in a private window.

If it's consent

Decide whether Maps needs consent on your site, and set the tool up so declined visitors see a placeholder that explains why and links to the location on Google Maps.

If it's the hostname

Add every hostname to the key's website restrictions, for example https://example.com/* and https://www.example.com/*, or redirect all traffic to one hostname. See fixing referrer restrictions.

If it's the visitor's extension, network or country

You can't fix their network, but you can make sure a blocked map doesn't leave a hole in the page. Put the address in plain text next to the map, add a link to the location on Google Maps, and handle the API failing to load in your own code:

JavaScript
const mapEl = document.getElementById("map");
try {
  const { Map } = await google.maps.importLibrary("maps");
  new Map(mapEl, { center: { lat: 51.5072, lng: -0.1276 }, zoom: 14 });
} catch (err) {
  // The API didn't load: blocked, offline or a bad key.
  mapEl.innerHTML = '<a href="https://www.google.com/maps/search/?api=1&query=Your+Address">Open our location in Google Maps</a>';
}

Because the call sits inside try, the fallback also runs when the script was blocked and google doesn't exist at all. Top-level await needs a type="module" script, or wrap the code in an async function. A self-hosted image of the map, with the address underneath, is the most robust fallback because it doesn't depend on any Google host.

If it's a Content-Security-Policy

A CSP blocks Maps for every visitor, not just some. If you see CSP violations in your own console, that's a site problem. See the CSP directives Maps needs.

Confirm it is fixed

Repeat the reproduction steps: private window, consent declined and accepted, each hostname, and mobile data. Then ask the customer to reload with a hard refresh. To catch the next regression before customers do, monitoring can re-scan up to five pages for free and email you when a map breaks.

Common questions

What does ERR_BLOCKED_BY_CLIENT mean on a Google Maps request?

The visitor's browser cancelled the request before it was sent, almost always because of an ad-blocker or privacy extension. Your site and your key are not at fault.

Can I make Google Maps work through an ad-blocker?

Not reliably, and you shouldn't try to proxy or self-host the Maps script, because Google rejects that with NotLoadingAPIFromGoogleMapsError. Show the address and a link as a fallback instead.

Why does the map work on my phone but not my customer's?

Different networks, extensions, consent choices and cached versions of the page. Test in a private window over mobile data, and with consent declined, to get closest to a first-time visitor.

Could my API key be the problem if only some people see the error?

Yes, if those people use a hostname the key doesn't allow, or if a daily quota runs out after your own check. Both show a Maps error code in the console, unlike an extension block.

Check whether this is your error

A scan tells you in about twelve seconds, from a clean session.

Related articles