PHP Warning: fsockopen(): unable to connect (Connection timed out)


PHP Warning:fsockopen(): unable to connect to (Connection timed out) in /home/public_html/pinger.php on line 66

Error type: warning


You try to open a socket to a remote location, but your connection is timed out (you don’t receive any response).

Sample Code:

$fs = fsockopen($ping_host, $ping_port, $errno, $errstr);

if (is_resource($fs))
fwrite($fs, $http_request);
while (!feof($fs))
$response .= fgets($fs, 2048);


The host you are trying to connect to is either down or takes too long to respond (or from other reasons, you just can’t get a response).


Get a beer, watch a movie, play a game … really, there’s not much you can do usually. Wait a few minutes and try again. If you still get the same response check if there is any problem with your server (for example DNS problems), eventually contact your hosting provider.

5 thoughts on “PHP Warning: fsockopen(): unable to connect (Connection timed out)”

  1. Thanks for the tip man. I really had problems with this. ssl::// doesn’t work. Do you have other ideas how to resolve the problem.

  2. Nice post. I was checking continuously this weblog and I am impressed!
    Extremely helpful info particularly the remaining section 🙂 I
    care for such information much. I used to be looking for this certain info
    for a long time. Thank you and good luck.

Leave a Reply

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

Security question: * Time limit is exhausted. Please reload the CAPTCHA.

This site uses Akismet to reduce spam. Learn how your comment data is processed.