How to resolve "Temporary failure in name resolution" issue

November 5, 2017 32.9k views
LAMP Stack Ubuntu 16.04

I rebooted my server (Ubuntu 16.04 w/ LAMP) about ~14 hours ago. Since then, I can't run apt-get or ping, and I'm seeing a lot of "Temporary failure in name resolution" errors in my syslog.

Here's the output when I run apt-get:

Err:1 xenial-security InRelease
  Temporary failure resolving ''
Err:2 stable InRelease
  Temporary failure resolving ''
Err:3 xenial InRelease
  Temporary failure resolving ''
Err:4 xenial-updates InRelease
  Temporary failure resolving ''
Err:5 xenial-backports InRelease
  Temporary failure resolving ''
Err:6 main InRelease
  Could not resolve host:
Reading package lists... Done
W: Failed to fetch  Temporary failure resolving ''
W: Failed to fetch  Temporary failure resolving ''
W: Failed to fetch  Temporary failure resolving ''
W: Failed to fetch  Temporary failure resolving ''
W: Failed to fetch  Could not resolve host:
W: Failed to fetch  Temporary failure resolving ''
W: Some index files failed to download. They have been ignored, or old ones used instead.

I suspect it's a DNS issue, but I'm not sure how to resolve. What should I look for?

3 Answers
TorWater November 8, 2017
Accepted Answer

I have this issue too. I suspect there is an issue with DigitalOcean's nameservers, so this will likely affect a lot of other people too.
Here's what I've done to temporarily get around it - but someone else might be able to advise on a better long-term fix:

1) Make sure your DNS Resolver config file is writable:
sudo chmod o+r /etc/resolv.conf

2) Temporarily change your DNS to use Google's nameservers instead of DigitalOcean's:
sudo nano /etc/resolv.conf

Change the IP address in the file to:

Press CTRL+X to save the file.

This is only a temporary fix as this file is automatically written/updated by the server, however I've not yet worked out what writes to it so that I can update it permanently.

I eventually found a similar solution. resolv.conf was the source of the issue; it was empty after I rebooted.

My fix:

  • I created a new Droplet, then copied the values that were populated in /etc/resolv.conf
  • On my original Droplet, I populated resolv.conf with the values from step 1
  • Done.

Note: After I applied this fix, DigitalOcean Support also suggested I add a firewall rule: enable DNS on port 53 TCP/UDP (inbound and outbound).

However, I haven't had to reboot my Droplet since creating the new firewall rule, so I haven't confirmed if it helps.

Have the same problem.

In /etc/resolv.conf there is the text:


UFW was the problem in my case.

sudo ufw allow out 53,113,123/udp

the problem was solved.

Have another answer? Share your knowledge.