I currently work on an older project that uses OpenCMS and I have to add reCaptcha v2 on a contact form.
Open CMS is installed on a different VM then the app server and both of them have access to google.com
But when I add
<script src="https://www.google.com/recaptcha/api.js" async defer></script>
And
<div class="g-recaptcha" data-sitekey="site_key"></div>
nothing happened. When I load the page it only inserts a blank spot.
I tried adding the <script> part in the html which only has <body> but also in the template that adds the <head> tag. I can see both of these lines when I inspect the page but no captcha.
I also tried with
<script src="//www.google.com/recaptcha/api.js?onload=renderReCaptchaCallback;render=explicit" async defer></script>
I should mention that the test environment is hosted on another VM using Apache which also has access to 8.8.8.8 maybe this could be helpful
Just a guess.
Can you check, if a CSP (content security policy) of your webserver blocks external scripts?
You should be able to see that in the network tab of your browser. You can find more info about CSP here:
https://content-security-policy.com/script-src/
HTH
Best regards Kai