2
votes

Sample code:

$html = file_get_contents('http://www.google.com');
echo $html;

It works on localhost. But after uploading to the webserver, it gives me a warning: file_get_contents(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution. If I replace the domain name with google's IP address, it gives a warning: failed to open stream: Connection timed out.

And ini_get("allow_url_fopen") return 1.

===
Edit: Probably it is a server problem. I guess this question should be asked on serverfault.com.

2
Can you execute a shell command from the webserver to ping Google? Also, what webserver are you currently using, Apache? Also, are you using DHCP?Anthony Forloney
@Anthony - ping does not work since ICMP is blocked. I am using apache. Not using DHCP. It turns out that it is a server problem. I guess I should ask on serverfault.comEthan

2 Answers

1
votes

Your host is most likely refusing the outbound connection. It's the only thing I can think of.

1
votes

This is a known bug in some versions of PHP. Tell your host about the problem and ask them to upgrade PHP.

It's also possible that your host have extremely naive firewall rules in place blocking just about any networking you try to do. Which host is it?