Question

How to resolve "Temporary failure in name resolution" issue

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 http://security.ubuntu.com/ubuntu xenial-security InRelease
  Temporary failure resolving 'security.ubuntu.com'
Err:2 http://dl.google.com/linux/mod-pagespeed/deb stable InRelease
  Temporary failure resolving 'dl.google.com'
Err:3 http://mirrors.digitalocean.com/ubuntu xenial InRelease
  Temporary failure resolving 'mirrors.digitalocean.com'
Err:4 http://mirrors.digitalocean.com/ubuntu xenial-updates InRelease
  Temporary failure resolving 'mirrors.digitalocean.com'
Err:5 http://mirrors.digitalocean.com/ubuntu xenial-backports InRelease
  Temporary failure resolving 'mirrors.digitalocean.com'
Err:6 https://repos.sonar.digitalocean.com/apt main InRelease
  Could not resolve host: repos.sonar.digitalocean.com
Reading package lists... Done
W: Failed to fetch http://mirrors.digitalocean.com/ubuntu/dists/xenial/InRelease  Temporary failure resolving 'mirrors.digitalocean.com'
W: Failed to fetch http://mirrors.digitalocean.com/ubuntu/dists/xenial-updates/InRelease  Temporary failure resolving 'mirrors.digitalocean.com'
W: Failed to fetch http://mirrors.digitalocean.com/ubuntu/dists/xenial-backports/InRelease  Temporary failure resolving 'mirrors.digitalocean.com'
W: Failed to fetch http://security.ubuntu.com/ubuntu/dists/xenial-security/InRelease  Temporary failure resolving 'security.ubuntu.com'
W: Failed to fetch https://repos.sonar.digitalocean.com/apt/dists/main/InRelease  Could not resolve host: repos.sonar.digitalocean.com
W: Failed to fetch http://dl.google.com/linux/mod-pagespeed/deb/dists/stable/InRelease  Temporary failure resolving 'dl.google.com'
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?


Submit an answer


This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

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: 8.8.8.8

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.

Bobby Iliev
Site Moderator
Site Moderator badge
February 5, 2021

Hello,

Just came across this question in 2021. As the /etc/resove.conf is managed by systemd-resolved, it should not be edited directly.

You can do that by updating the /etc/systemd/resolved.conf file instead, and under the [Resolve] section set:

[Resolve]
DNS=1.1.1.1 8.8.8.8
FallbackDNS=8.8.4.4

After that restart systemd-resolved:

systemctl status systemd-resolved

Finally to make sure that the change was successful check the status:

systemd-resolve --status

Hope that this helps. Regards, Bobby

My issue was related to a wrong datetime. After executing rdate -uns 83.91.10.45 ist was solved.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel