I'm at my wits end with this one. I have apache running on a server of mine (an Amazon ec2 instance), and I can't seem to resolve domain names in php. For example fopen('http://www.google.com', 'r') will throw "php_network_getaddresses: getaddrinfo failed: Name or service not known", but if I change the url to one of google's ip addresses it will work fine. Pinging www.google.com on the remote server works fine as well so I know its not a problem with the "outer system."
The peculiar thing is that I've had this server up and running for a while without any issues and I can't think of anything I did that could have caused this.
In my php.ini I have allow_url_fopen = On and to make sure it was being applied I ran phpinfo() from the same script that is having this problem and allow_url_fopen is in fact turned on.
Any ideas of what else I should try? Could some sort of file permissions problem be causing this? Because I did change some file permissions inside my webapp, and I suppose its possible I mistyped something and accidentally changed permissions/owenership of some files outside of the app. Its highly unlikely but I can't think of anything else I did on the system that could have stopped this from working.
I had the same problem.
After httpd restart host resolve problem continues. But with httpd stop & start problem solved for me.
If you have permission, try changing the name servers in your /etc/resolv.conf file to other nameservers. Might be your dns cache is old,
or try changing the SE Linux Policy by running these commands in terminal:
setsebool -P nis_enabled 1
setsebool -P httpd_can_network_connect 1
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With