reCAPTCHA ERROR: Invalid domain for site key

I have implemented my reCAPTCHA in line with as is shown in the example.

I have this script in the head tag:

<script src="https://www.google.com/recaptcha/api.js"></script>

In my form in HTML I have:

<div class="g-recaptcha" data-sitekey="my public sitekey here"></div>

But when I load the form I get this error:

ERROR: Invalid domain for site key

I have confirmed that this is the correct site key for my domain.

The code is currently in a subdomain so I thought maybe that was the problem so I also added the subdomain to the Google reCAPTCHA admin but still get the error.

The exact same code works 100% in a different domain (with a key specific to that domain).
What could be the problem?


Solution 1:

In case someone has a similar issue. My resolution was to delete the key that was not working and got a new key for my domain. And this now works with all my sub-domains as well without having to explicitly specify them in the recaptcha admin area.

Solution 2:

First of all, the keys are managed at https://www.google.com/recaptcha/admin#list

I ran into this error because I'm using the same key on a few different domains and I had forgotten to add one of the domains to the key.

After adding my site it took a minute or two (most likely because of cache) for things to work normally again.

Solution 3:

I had the same problems I solved it. I went to https://www.google.com/recaptcha/admin and clicked on the domain and then went to key settings at the bottom.

There I disabled the the option below Domain Name Validation Verify the origin of reCAPTCHA solution

clicked on save and captcha started working.

I think this has to do with way the server is setup. I am on a shared hosting and just was transferred without notice from Liquidweb to Deluxehosting(as the former sold their share hosting to the latter) and have been having such problems with many issues. I think in this case google is checking the server but it is identifying as shared server name and not my domain. When i uncheck the "verify origin" it starts working. Hope this helps solve the problem for the time being.

Solution 4:

No need to create a new key just clear site data on browser

If you change your site domain then add that domain to existing key (it's not necessary to a create new one) and save it.

https://www.google.com/recaptcha/admin#list

but google recapture has some data on browser. Clear them then it will work with your new domain enter image description here