4

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.

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

1 Answer 1

0

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.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .