Could Not Open Socket reCAPTCHA Error


The weirdest thing happened with Recaptcha, when I moved from shared hosting to a VPS with PHP 5.3.

I started to get could not open socket error on one of my sites, I searched and searched all over but couldn’t find the answer.

What was even more odd was that another site that I had on the same server worked fine.

After searching for about 6 hours, I finally found a solution.

All I did was change the following code in recaptchalib.php file.

First open the file and look for:

define(“RECAPTCHA_API_SERVER”, “http://www.google.com/recaptcha/api”);
define(“RECAPTCHA_API_SECURE_SERVER”, “https://www.google.com/recaptcha/api”);
define(“RECAPTCHA_VERIFY_SERVER”, “www.google.com”);

and change it to the following:

define(“RECAPTCHA_API_SERVER”, “http://www.google.com/recaptcha/api”);
define(“RECAPTCHA_API_SECURE_SERVER”, “https://www.google.com/recaptcha/api”);
define(“RECAPTCHA_VERIFY_SERVER”, “74.125.227.48”);

If you notice the only thing changed was www.google.com to and IP of google’s which I found to work was 74.125.227.48

Some suggested that globals should be turned on, but the site that was working properly had globals turn on, so it didn’t make any sense when I turned off globals and it still didn’t work.

This is the easiest and simplest way to fix this problem, no need to mess with php.ini and also .htcacces file.

I tried to even contact Recaptcha but wasn’t successful, and no way to contact them, plus they are now a part of Google, so it’s even harder to get in touch with someone.

If you have another solution, I’m open to suggestions.

 

 


Posted in IT Support.

Leave a Reply