My droplet is running Ubuntu 14.04.4 LTS. I tried running the following command:
sudo apt-get update
but got errors like:
Temporary failure resolving 'mirrors.digitalocean.com'
Pinging 8.8.8.8 works. Pinging google.com results in:
ping: unknown host google.com
I found other people with a similar problem, but none of the solutions in the other threads worked, such as forcing IPv4 by uncommenting precedence ::ffff:0:0/96 100
in /etc/gai.conf.
Disabling IPv6 with /etc/sysctl.conf did not fix the DNS problems either. Is there something else that could be wrong? I tried the above commands with and without ufw enabled.
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!
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.
Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.
Hey @DC2R - Take a look at this answer the wonderful @jellingwood provided to a user with a similar problem.
Reproduced here:
First, the failure to fetch the new package updates seem to be related to DNS. Depending on a few different things sometimes your network configuration will be configured to rely on IPv6 name servers. This can become a problem if we are blocking IPv6. We can easily change the settings to use IPv4 servers however.
First, open up the network configuration file in your text editor:
Inside, you should see a few different configuration blocks, one for each of your configured network interfaces. Only one of these will define a parameter called
dns-nameservers
. This is the option we need to modify. We can change the value to use the8.8.8.8
and8.8.4.4
name servers, both of which are reliably operated by Google:Save and close the file when you’ve change that value.
Next, we can modify the behavior of the
getaddrinfo
configuration file. This will help us control whether IPv4 or IPv6 destinations are preferred if we are given a choice. We can change this behavior by modifying the/etc/gai.conf
file:Inside, find and uncomment this line:
This will tell your system to always choose IPv4 when given the choice. Save and close the file when you have uncommented the line above.
Now, we just need to restart our network interface to use our new DNS settings. Assuming that the network interface in question is
eth0
, you can stop and quickly restart the interface, reading the new configuration changes, by typing:You will have a momentary pause in your connection to the server as the network is adjusted.
After that, all of your services, including
apt
, will prefer IPv4. That should fix the issue you are seeing.