58

I tried to set up reCAPTCHA, on my page by following the instructions here. I signed up for an API key pair and was issued a public key and a private key. It was not clear, to me, how the private key should be used and I could not find more information about it. It does not appear to be used on the page where reCAPTCHA is called.

I edited my page and put

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

before the closing </head> tag on my HTML template.

I also put

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

where I want my reCAPTCHA widget to appear.

When I load my page, I get the message

Cannot contact reCAPTCHA. Check your connection and try again.

I also see the reCAPTCHA widget with the text

ERROR for site owner: Invalid site key

I have checked similar questions such as this, where the answer says the key is probably invalid but I have just generated it. I also saw this but I did not disable

Verify the origin of reCAPTCHA solutions

15 Answers 15

116

It wasn't obvious to me initially, but you have to supply your site key in 2 places:

  1. In the render querystring parameter in the script source tag
  2. As the first parameter of the javascript execute() method

enter image description here

5
  • 8
    How could I overlook that? Thank you! Commented Apr 27, 2020 at 16:43
  • 8
    Yeah, even today, the reCaptcha docs are... under developed.
    – spencer741
    Commented Feb 23, 2021 at 5:48
  • 2
    It was obvious to me, but as I was trying v2 and then v3, I forgot to change the key on both places.. Commented Jun 21, 2021 at 11:22
  • 1
    I'm not sure if we have more than one subdomain we must create new keys. I did it and following this answer I fixed.
    – papesky
    Commented Dec 9, 2021 at 12:00
  • 1
    @Matthew your image got corrupted. Please mention the places name where we can add the site key. Commented Jan 24, 2023 at 3:31
27

You need to ensure your site is added in the domains section of the google reCAPTCHA page where you generated the API key and save. Then test again. That worked for me.

1
  • 1
    That was part of it. I had added my IP address instead of the site name. Also, there was a file, insert.php, that needed the correct private key. Commented Mar 3, 2018 at 17:17
10

In my case it was using a wordpress site,

And I had chosen version 3 of captcha and it turns out the wordpress only supported version 2.

3
  • 1
    Although I am stuck while integrating V3 in WordPresss but I strongly doubt what you are saying and thinks WordPress support V3 because WordPress is just simple PHP so there is no hard and fast rule if PHP supports it then WordPress also supports it. Commented Mar 2, 2019 at 18:33
  • It has nothing to do with being a Wordpress site.
    – wickywills
    Commented Mar 5, 2019 at 11:38
  • I have just implemented v3 in wordpress, it works fine. Issue is most likely you are using a plugin.
    – Guerrilla
    Commented Aug 15, 2021 at 18:15
5

I also face same problem from google reCAPTCHA console your project uncheck

  1. Verify the origin of reCAPTCHA solutions
  2. Send alerts to owners

both,then see from your contact form, its working from me just try it

Hope this helps!

0
4

I'm using Entrepreneur Wordpress theme which came with Formidable. I went to the reCAPTCHA Admin Console and created the Site and Secret Keys for "V2 Checkbox."

At first it wasn't working and I was getting the "ERROR for site owner: Invalid site key" message but figured out that the reason why was because I had put the "http://" before my domain.

After trial and error, I discovered that deleting the old reCAPTCHA for that domain, then creating a new one without the "http://" worked perfectly! Not sure if having or not having the "www." would matter for any other users.

Hope this helps!

1
  • I have added domain without www and added only site domain help me. Remove www works for you. Commented Mar 6, 2019 at 4:54
1

I had the same issue with reCAPTCHA v3 on my blog on Wordpres 4.5. When I replaced reCAPTCHA v3 with reCAPTCHA v2 the issue has gone.

1

Double check that you are using the "Site Key" and not the "Secret Key" inside the Google ReCaptcha settings. They look quite similar, so it's easy enough to make this mistake.

1

I had same issue in my React app,recaptcha v3 give me error,reCapcha v2 works fine.Just change the version from v3 to v2,copy and paste site key and works like a charm.

1

I also had to change from the reCaptcha type: v3 to v2. It's worked in my case. I think the reCaptcha docs are underdeveloped

3
  • 1
    Where did you make this change? Commented Nov 10, 2023 at 22:37
  • can you explain what you actually did ?
    – Choco
    Commented Nov 26, 2023 at 3:17
  • 1
    I Downgraded the reCaptcha version. In 2021, I was unable to use v3. But now, you guys can look into it.. Maybe it works.
    – shoaib21
    Commented Nov 27, 2023 at 5:13
1

In my case, I'm using Contact Form 7 plugin inside my WordPress CMS-based website, the problem was because I'm filtering/removing the query string from the enqueueing scripts e.g. script.js?**v=1.2**:

function mb_remove_script_version($src)
{
  $parts = explode('?', $src);
  return $parts[0];
}

add_filter('script_loader_src', __NAMESPACE__ . '\\mb_remove_script_version', 15, 1);
1

Ensure you are using the correct recaptcha version. As of writing this post there is

Google reCAPTCHA V2

Google reCAPTCHA V3

Google reCAPTCHA Enterprise

0

Google stopped supporting TLS 1.0, make sure you making request with TLS1.1 or TLS 1.2

Use ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; for .NET 4.5 and lower version

0

I had this problem with Wordpress Contact Form plugin. Be sure that you have put correct domain at reCAPTCHA configure page. It should be without http:// or https://. For example, google.com. Regenerate api keys and update it in Admin/Contact/Integration. Then you will see recaptcha icon in the page bottom corner

1
  • Incorrect: According to reCaptcha: A valid domain requires a host and must not include any protocol, path, port, query or fragment.
    – blnks
    Commented Nov 20, 2023 at 6:28
0

I removed  following <div class="g-recaptcha" data-sitekey="***site-recaptcha-key****"></div> from the page and V3 still sending the reply as intended and the error is gone now. Tested and it does work as needed. 

0

I had simply forgotten to add the recapcha credentials to my production ENV file, thus only supplying "none" in the script tag.

Not the answer you're looking for? Browse other questions tagged or ask your own question.