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

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']) &&
$a_url['host']!=gethostbyname($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:
'.$a_url['host']."\r\n\r\n");
$head = fread($fid, 4096);
fclose($fid);
return preg_match('#^HTTP/.*\s+[200|302]+\s#i', $head);
} else {
return false;
}
}

.



Relevant Pages

  • RE: PHP5 as apache module using packages
    ... Ok so i've reinstalled fBSD-7 and i'm running apache 2.2 installed using ... I need to also run php as a module for apache (the web software i'm using ... for a world of warcraft guild, ...
    (freebsd-questions)
  • Re: Mail() Function
    ... I am running apache 2.2.6-1.fc7. ... I am now writing a site that will require the sending of forms by php ... What is the minimum I need to configure on my apache development server ... local machine will be stored in the local inbox. ...
    (alt.php)
  • Re: [PHP] A Guide to running Apache 2, PHP 4 & PHP 5 on Windows XP
    ... guide to installing, configuring and running Apache 2, PHP 4.4.7 and ... PHP 5.2.2 on Windows XP. ... The guide is broken down into small ...
    (php.general)
  • RE: [PHP] Time
    ... If you change the time zone on your Linux server ... running Apache and PHP, you need to Stop and then Start Apache else the PHP ...
    (php.general)
  • Re: [PHP] gethostbyname () uses old DNS server
    ... the PHP programs keep using the old DNS server IP. ... > then tcpdump shows that it is accessing the new DNS server. ...
    (php.general)