reCAPTCHA error Unable to open socket

reCAPTCHA error Unable to open socket

After months of receiving spam through my contact forms I decided it was time to add reCAPTCHA to them in hopes of stemming the tide of spam. It is now under the control of Google. I thought there would be no problem with that. Having just installed reCAPTCHA on my work websites, I knew what to do and everything went well on those sites. On Friday I made 3 forms on my own sites and they all worked as expected, on Saturday I made the last form I had but this one didn’t work. All I was getting was a “cannot open socket” error.

At first I thought I must have made some mistake in the code, but after checking the code against the one I had made the day before, I saw no mistake. And more than that the 3 forms I made the other day that were working are now no longer working and showing the same error message, what the heck?? Most disappointing was the fact that that was all the message said and gave no clue as to what was causing it. I made several attempts to find which part of the code was wrong by adding echo throughout the php code, but none of them showed up, just this damn error message. I thought there must be something wrong with the server.

Someone must have had this problem before, so I turned my attention to Google for an answer. When I started typing “can’t open socket” the autocomplete came up with “can’t open socket recaptcha” ha ha! But I couldn’t think why it could work yesterday and not today? After reading a lot of useless posts, I found this: which, although it didn’t have the exact answer, helped me figure out the answers to my own problems.

After reading this thread I came to the conclusion that my problem is 2 times and explained why it worked yesterday and not today. The main problem was my web host, in an attempt to be helpful they introduced (a long time ago) blocking outgoing connections to remote IP addresses from my sites. This is something to be aware of, if you auto blog using wp-o-matic, any feed you add will most likely be blocked by this until you add the IP to the whitelist from your control panel.

I suppose there’s a good reason they do this, but one can imagine it caused nightmares for the inexperienced. Apparently it had worked yesterday because it was new, once the server realized the connection was going through it blocked it. Probably the number of tests I did made the link get noticed and maybe it was a good job it got noticed so quickly or I might not have noticed it for a while.

So which IP should I have added to the whitelist? The line of code in recaptchalib.php identified as the problem in the above thread was:


So what I needed was the IP address. is a very useful tool that I have been using for a long time. A DNS lookup for gave me 5 IP options, to, so now I have:


Adding this IP address to the list of allowed remote IP addresses from my control panel sorted the problem on all my forms. Result!

#reCAPTCHA #error #Unable #open #socket

Leave a Comment

Your email address will not be published. Required fields are marked *