Home > Uncategorized > Temporary failure in name resolution #Fix #Linux #PHP

Temporary failure in name resolution #Fix #Linux #PHP

Firefox-having-DNS-issues-Ubuntu-17.04

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.

 

Advertisements
Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: