PHP file_get_contents () not working after uploading to web server

Sample code:

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

      

It runs on localhost. But after uploading to the webserver, it gives me a warning: file_get_contents (): php_network_getaddresses: getaddrinfo failed: temporary failure to resolve name. If I change the domain name to google IP, it gives warning: failed to open stream: connection timed out.

And ini_get ("allow_url_fopen") returns 1.

===
Edit: This is probably a server issue. I assume this question should be asked on server.com.

+2


a source to share


2 answers


Your host will most likely refuse the outgoing connection. This is the only thing I can think of.



+1


a source


This is a known bug in some PHP versions. Report the problem to the owner and ask for a PHP update.



It is also possible that your host has extremely naive firewall rules that block just about any network you try. Which host is this?

+1


a source







All Articles