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.

Leave a Reply

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

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