php unable to resolve DNS?

i have a centos 4.1 server with php 4x. If I write a php script with the following:

echo file_get_contents('http://www.google.com/'); I get the following error:

Warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /filename

if I use:

echo file_get_contents('http://ipaddress/'); it works fine

if I ping www.google.com from my server it resolves to the IP without a problem. And if I add the IP/host to /etc/resolv.conf the PHP script will work.

My question is, why is php unable to resolve the domain on it's own?

 

 

 

 

Top