Knowledge base / API keys

Fix MissingKeyMapError on Google Maps

The script that loads Google Maps reached Google without any API key attached. Google never got as far as checking a key, because there wasn't one. Something on your site is building the loader URL and leaving the key out.

How to tell this is your problem

  • The map loads grey with the “Oops! Something went wrong.” overlay for every visitor.
  • The console shows MissingKeyMapError, usually with a NoApiKeys warning just before it.
  • In the page source, the maps/api/js URL has no key= parameter, or has key= followed by nothing.
  • The map broke after a theme or plugin update, a switch to a new theme, a site migration or a fresh deployment.

This is what the console shows:

Google Maps JavaScript API warning: NoApiKeys
Google Maps JavaScript API error: MissingKeyMapError
https://developers.google.com/maps/documentation/javascript/error-messages#missing-key-map-error

If the key is present but wrong, you get InvalidKeyMapError instead. That needs a different fix, covered in the InvalidKeyMapError guide.

Why it happens

Google's documentation describes this error simply: the script element that loads the API is missing the required authentication parameter. For almost every site today that parameter is key. Sites still on a legacy Premium Plan client ID pass client instead, which has its own problems covered in the client ID guide.

The key is rarely deleted on purpose. These are the usual causes, most likely first:

  • An empty settings field. A theme or maps plugin builds the loader from a settings page. After an update, a reinstall or a theme switch, that field is blank, and the plugin still outputs the script with no key.
  • A second loader. Another plugin, page builder widget or theme component injects its own copy of the Maps script and has no key configured. The page may load the API twice, and the keyless copy is the one that fails. See duplicate Maps loaders in WordPress.
  • An unset environment variable. In a JavaScript build, the key comes from something like process.env.MAPS_KEY or import.meta.env.VITE_MAPS_KEY. If the variable exists locally but not in your production build settings, the key renders as an empty string.
  • A hand-edited embed. Someone copied a snippet from a tutorial and removed the placeholder YOUR_API_KEY rather than replacing it.
  • A migration that dropped settings. Exporting and importing a site often brings content across but not plugin options, so the map widget arrives without its key.
  • An old v2 loader path. Google notes that loading the API from the deprecated v2 path triggers the NoApiKeys warning even when a key is specified. Old themes sometimes still use it.

The fix, step by step

  1. 01Open the broken page, choose View source, and search for maps/api/js. Note every match. If there is more than one, you have more than one loader, and each needs checking.
  2. 02For each loader URL, look for key=. If it is absent or empty, that loader is the problem. The surrounding HTML, an id attribute or a script handle usually tells you which theme or plugin printed it.
  3. 03Find your existing key in Google Cloud Console under APIs & Services → Credentials, in the project you use for Maps. If you have no key, create one and set its application restrictions (your websites) and API restrictions (at least the Maps JavaScript API) before you use it.
  4. 04Paste the key into the settings field that controls that loader. Paste it with nothing around it: no spaces, quotes or line breaks.
  5. 05If a second plugin injects its own keyless loader, either give it the same key or switch off its map feature, so only one copy of the API loads.
  6. 06Clear any page cache, optimisation plugin cache and CDN cache, then reload the page in a private window.
Check the key's restrictions too

Once the key is back in the URL, Google starts checking it. If the key's website restrictions don't include your domain you'll move straight on to RefererNotAllowedMapError, and if its API restrictions leave out the Maps JavaScript API you'll see ApiTargetBlockedMapError. Both are quick to fix, and both mean the missing key problem is solved.

WordPress and page builders

WordPress sites are where this error turns up most. A key can live in several places at once: the theme options panel, a dedicated maps plugin, a page builder's global integrations screen and individual map widgets. A widget can ignore the global key or override it with an empty value of its own.

Work through each one. Our guide to where each page builder stores the Maps key lists the settings screens for Elementor, Divi, WPBakery and others. If the map is a native block on Wix, Squarespace or Shopify, the platform manages the key and you usually can't add one yourself. See platform map blocks.

If you load the API in your own code

Make the build fail loudly when the key is missing, instead of shipping a keyless loader:

JavaScript
const key = import.meta.env.VITE_MAPS_KEY;
if (!key) {
  throw new Error("VITE_MAPS_KEY is not set for this build");
}

(g=>{/* Google's inline bootstrap loader, copied unchanged from the docs */})({
  key,
  v: "weekly",
});

Then check your hosting provider's environment variable settings for the production and preview environments separately. A variable set only for preview builds is a common cause. Remember that frameworks only expose variables with the right prefix to browser code, so a correctly set variable with the wrong name still arrives empty.

Confirm it is fixed

Reload the page with the browser console open. The NoApiKeys warning and MissingKeyMapError should both be gone, and the map tiles should load. View the source again and check every maps/api/js URL now has the same key.

Then run a scan. It loads the page from a clean session with no cache and lists every Maps loader request it sees, so a second keyless loader or a stale cached page shows up straight away.

Common questions

What is the difference between MissingKeyMapError and InvalidKeyMapError?

MissingKeyMapError means no key was sent at all. InvalidKeyMapError means a key was sent but Google doesn't recognise it, usually because it was mangled, truncated or deleted.

Can I use Google Maps without an API key?

Not with the Maps JavaScript API. It needs a key on a Cloud project with billing enabled. A simple embedded map from Google Maps' share option uses an iframe instead, and that route doesn't need a key in your page.

Why did the error appear after a theme update?

Many themes store the Maps key in their own options. An update, a reset or a switch to a child theme can leave that option empty, and the theme then prints the loader without a key.

Does it matter if my map plugin and theme both load Google Maps?

Yes. Loading the API twice causes errors of its own, and if one copy has no key you get MissingKeyMapError even though the other copy is configured correctly. Keep one loader and give it the key.

Check whether this is your error

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

Related articles