Fixing Invalid Domain Errors in Google reCAPTCHA

0
18

You’ve added Google reCAPTCHA to your website. Everything should be smooth, right? But now, you’re staring at this message: “ERROR: Invalid domain for site key.” What just happened?! Don’t worry — this is a very common issue, and it’s totally fixable.

Let’s break it down and fix it together, step by step. And yes, we’ll keep it short, sweet, and fun!

What Does “Invalid Domain for Site Key” Mean?

Google reCAPTCHA checks the domain name of your website. If it doesn’t match the one you registered with Google, it throws this error.

In simple terms: You told Google your site was at one address, and now you’re using reCAPTCHA on another. Google doesn’t like surprises.

Step 1: Identify the Domain Problem

First, note where you’re running your website. Is it:

  • mystunningwebsite.com
  • www.mystunningwebsite.com
  • dev.mystunningwebsite.com
  • localhost (for local testing)

Each of those is slightly different in Google’s eyes. Even www.mystunningwebsite.com is different from just mystunningwebsite.com.

Step 2: Check Your Site Key Settings

Head over to your Google reCAPTCHA admin console:

Find your site key on the dashboard and click it. Under “Domains”, you’ll see the list of allowed domains. Make sure the one you’re using is listed!

Not sure if you should include www? It’s best to list both versions:

  • example.com
  • www.example.com

Also, if you’re running on localhost during testing, you’ll need to add localhost to your domain list.

Step 3: Add or Edit Domains

If the domain isn’t listed, click the settings icon on the top right of the reCAPTCHA admin page.

Then, under “Domains” or “Authorized domains”, add the correct one.

Tip: Don’t include http:// or https:// or any path like /login. Only the domain part goes here.

Example:

  • Correct: yoursite.com
  • Wrong: https://yoursite.com/login

Click Save, and boom, done!

Step 4: Wait a Tiny Bit

Changes to the domain list don’t always show up instantly. Give it a few minutes. Then refresh your page or clear your browser cache and try again.

Step 5: Check Your reCAPTCHA Code

Double-check that your site key is correctly used in your website’s HTML. Somewhere in your code, it should look like:

<div class="g-recaptcha" data-sitekey="your-site-key"></div>

If you copied the wrong site key (for example, one from another project), you’ll get the domain error too.

Extra Tips and Pro Tricks

  • Register separate keys for live and dev sites. This helps avoid confusion.
  • Check console errors in your browser. They can give clues about what’s wrong.
  • If you switched from v2 to v3 (or vice versa), update your implementation. Mixing versions won’t work.

Still Stuck?

Sometimes, it’s not your code at all. Clear your browser cache or try in an incognito window. That alone solves many weird reCAPTCHA bugs.

And if nothing works, delete your key and register a new one — fresh start!

Wrap-Up

Invalid domain errors in Google reCAPTCHA can be annoying, but they’re easy to fix. Stick to the right domain, confirm it with Google, and make sure your code uses the matching site key.

Your website’s forms will be bot-proof and error-free in no time!