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

Message:

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

Error type: warning

Symptoms:

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

Sample Code:

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

if (is_resource($fs))
{
stream_set_write_buffer($fs,0);
fwrite($fs, $http_request);
while (!feof($fs))
{
$response .= fgets($fs, 2048);
}
fclose($fs);
}
?>

Cause:

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).

Fix:

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 Responses

  1. Allan Says:

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

  2. diablo Says:

    Saved as a favorite, I like your site!

  3. Nc James Says:

    Thanks for this post. it really solved my problem.

  4. Just a test Says:

    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.

  5. test.com Says:

    This is a topic which is close to my heart..
    . Thank you! Exactly where are your contact details though?

Leave a Reply

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

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