Okay, this question has been asked plenty of times around the internet, but I haven't found any solution that fixes the problem in my case.
I'm about to fetch some JSON data with this code:
$response = file_get_contents('http://www.domain.com/path/to/json');
And it's constantly stumbling over the following error:
file_get_contents(): php_network_getaddresses: getaddrinfo failed: Name or service not known
I'm running Debian with PHP 5.4.4 on Nginx 1.2.6 and php-fpm.
This is my troubleshooting so far:
- The URL exists and gives a valid result in the browser.
- I've ensured that
allow_url_fopen
is on in php.ini. - I've changed to Google Public DNS in
/etc/resolv.conf
. - Doing
ping google.com
works. - Switching to
http://0.0.0.0/path/to/json
works but is undesirable. - I've got a couple of domains pointing to the same server, and the same problem occurs independently.
I'm a bit concerned about the domain
in /etc/resolv.conf
, is it right?
# Automatically generated by OnApp (2.3.0-29)
domain localdomain
# Original DNS
#nameserver 10.0.10.10
#nameserver 10.0.11.11
# Google Public DNS
nameserver 8.8.8.8
nameserver 8.8.4.4
Any kind of help is appreciated.