Linux Can Ping An IP Address But Can't Resolve Domain Name

This fix for Linux helps when you can ping IP but can't resolve domain names in web browsers or cannot to connect to servers for updates.

By Tim TrottLinux Tips and Tutorials • August 29, 2012
Linux Can Ping An IP Address But Can't Resolve Domain Name

Domain names are a human-friendly version of IP addresses. The resolving process is a lookup between a name and an IP. For example, the IP address 172.217.17.68 resolves to www.google.com, and the domain name is far easier to remember than that long number.

On some Linux distributions, domain name resolving does not work out of the box. Typically, a package isn't installed, or a setup item wasn't completed properly. You may encounter Linux can errors such as:

Err:1 http://gb.archive.ubuntu.com/ubuntu xenial/main amd64 postfix amd64 3.1.0-3
  Temporary failure resolving 'gb.archive.ubuntu.com'

You may also find that you can ping IP addresses but can't resolve domain names, so ping 172.217.17.68 will work, but ping www.google.com will not.

The fix is quite easy. All you need to do is edit a file and add two lines telling the networking system where to look up domain names.

sudo pico /etc/resolv.conf

If this file is empty, then this is your problem. Add the following lines to the file, save it, and try to access the domain name again.

nameserver 8.8.8.8
nameserver 8.8.4.4

Now, you should be in business.

Related ArticlesThese articles may also be of interest to you

CommentsShare your thoughts in the comments below

My website and its content are free to use without the clutter of adverts, popups, marketing messages or anything else like that. If you enjoyed reading this article, or it helped you in some way, all I ask in return is you leave a comment below or share this page with your friends. Thank you.

There are no comments yet. Why not get the discussion started?

New comments for this post are currently closed.