469,636 Members | 1,976 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,636 developers. It's quick & easy.

Keep getting: php_network_getaddresses: getaddrinfo failed

Hi - I am using this url_exists function: to check whether files exist
on other peoples webservers (before allowing my users to add the site
to their directory of rss feeds). On my current shared hosting (running
Apache 1.3.29 Red Hat Linux PHP 4.3.10) the function works perfectly.
On my new, Plesk VPS system (running Apache 2.0.51 Fedora PHP 4.3.10)
it doesn't work - I get this error:

php_network_getaddresses: getaddrinfo failed

If the is the IP address then the error does not occur but if I try to
resolve the IP address using gethostbyname("webaddress") it simply
returnes the webaddress (e.g. bbc.co.uk returns bbc.co.uk - not the IP

It looks like the issue relates to the DNS server so apologies if this
is a server question not a PHP question - but as the issue is
manifesting itself only in my PHP I thought I'd ask here too.

Many thanks.

Here is the function:

function url_exists($url) {
$a_url = parse_url($url);
if (!isset($a_url['port'])) $a_url['port'] = 80;
$errno = 0;
$errstr = '';
$timeout = 5;
if(isset($a_url['host']) &&
$fid = fsockopen($a_url['host'], $a_url['port'], $errno,
$errstr, $timeout);
if (!$fid) return false;
$page = isset($a_url['path']) ?$a_url['path']:'';
$page .= isset($a_url['query'])?'?'.$a_url['query']:'';
fputs($fid, 'HEAD '.$page.' HTTP/1.0'."\r\n".'Host:
$head = fread($fid, 4096);
return preg_match('#^HTTP/.*\s+[200|302]+\s#i', $head);
} else {
return false;

May 7 '06 #1
0 1696

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Bernhard Schmidt | last post: by
4 posts views Thread by edcdave | last post: by
1 post views Thread by mirandacascade | last post: by
5 posts views Thread by _q_u_a_m_i_s's | last post: by
1 post views Thread by Karl Chen | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.