Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

If i try to run the following:

<?php echo file_get_contents("http://www.yahoo.com/index.html"); ?>

through the web server I get a an "php_network_getaddresses: getaddrinfo" error.

If I run the same file from the shell with:

php test.php

then I get the expected file output.

This indicates to me that the 'nobody' user, which the webserver runs as, is not able to resolve the domain name, but the shell user can.

Any ideas on how to fix this?

Further info: CentOS 6, cPanel install, Apache, PHP running as dso.

BTW, I've tried disabling the firewall to no effect.

[SOLVED] - when I found that gethostbyname() was working, I realised that it was some internal caching problem. A server restart seems to have sorted out the problem.

share|improve this question
1  
what's the output of echo ini_get('allow_url_fopen'); ? –  Sandman4 Apr 15 '12 at 15:47
    
@Sandman4 1 - that's the number one on it's own. –  jalal Apr 15 '12 at 16:19
    
and if you do echo gethostbyname('www.yahoo.com'); ? –  Sandman4 Apr 15 '12 at 16:25
    
then I get the IP number of yahoo.com (which i did not expect). –  jalal Apr 15 '12 at 16:31
4  
You should probably answer your own question, and then accept it, so you can close this question off. –  EightBitTony May 4 '12 at 9:12

1 Answer 1

up vote 0 down vote accepted

From later comment by jalal: "[SOLVED] - when I found that gethostbyname() was working, I realised that it was some internal caching problem. A server restart seems to have sorted out the problem."

Repeating EightBitTony comment - please mark this question as answered.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.