Temporary failure in name resolution #Fix #Linux #PHP
If you get this error message in PHP,
php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution
Then you are either calling a domain name that doesn’t exist, or your DNS resolution has failed on your server. Assuming you haven’t mistyped the API url, then you can check for a DNS issue by SSH’ing into your server and trying to ping http://www.google.com and see if you get a response. – If that fails, then you need to fix your resolving DNS servers, and perhaps contact your host company too.
Google offer their own DNS resolving servers for free, and you can use them as follows;
sudo echo nameserver 8.8.8.8 > /etc/resolv.conf
sudo /etc/init.d/httpd restart
Which changes the DNS resolver on your server to Google’s server with IP 8.8.8.8, and then restarts your web server. You may use apache2 here instead of httpd – depending on your flavour of linux.