How to Resolve “Temporary failure in name resolution” Issue

Sometimes when you try to ping a website, update a system or perform any task that requires an active internet connection, you may get the error message ‘temporary failure in name resolution’ on your terminal.

For example, when you try to ping a website, you might bump into the error shown:

tecmint@ubuntu:~$ ping google.com
ping: tecmint.com: Temporary failure in name resolution

This is usually a name resolution error and shows that your DNS server cannot resolve the domain names into their respective IP addresses. This can present a grave challenge as you will not be able to update, upgrade, or even install any software packages on your Linux system.

In this article, we will look at some of the causes of the ‘temporary failure in name resolution‘ error and solutions to this issue.

1. Missing or Wrongly Configured resolv.conf File

The /etc/resolv.conf file is the resolver configuration file in Linux systems. It contains the DNS entries that help your Linux system resolve domain names into IP addresses.

If this file is not present or is there but you are still having the name resolution error, create or open the /etc/resolv.conf file in a text editor with root privileges.

$ sudo nano /etc/resolv.conf
OR
$ sudo vim /etc/resolv.conf

Next, add Google’s public DNS servers with the nameserver keyword followed by the IP address of the DNS server.

nameserver 8.8.8.8
nameserver 8.8.4.4
Add DNS Name Servers
Add DNS Name Servers

Save the changes and restart the systemd-resolved service as shown.

$ sudo systemctl restart systemd-resolved.service

It’s also prudent to check the status of the resolver and ensure that it is active and running as expected:

$ sudo systemctl status systemd-resolved.service

Then try pinging any website and the issue should be sorted out.

$ ping google.com
Check Network Connection in Linux
Check Network Connection in Linux

After confirming your network connection, make sure to edit the /etc/resolv.conf file to prevent it from being overwritten by network management tools.

To do this, you can create a symbolic link to /dev/null:

$ sudo ln -sf /dev/null /etc/resolv.conf

Note: Some Linux distributions, especially those using NetworkManager, may automatically manage the /etc/resolv.conf file. If that’s the case, manually editing the file might not have a lasting effect.

Instead, you may need to configure DNS settings through the appropriate network management tool or configuration files for your specific distribution. Be sure to consult your distribution’s documentation or support resources for the recommended method of configuring DNS in such cases.

2. Firewall Restrictions

If the first solution did not work for you, firewall restrictions could be preventing you from successfully performing DNS queries. Check your firewall and confirm if port 53 (used for DNS – Domain Name Resolution ) and port 43 (used for whois lookup) are open. If the ports are blocked, open them as follows:

Open DNS Ports on UFW Firewall

On Debian-based distributions, you need to open ports 53 & 43 on the UFW firewall by running the commands below:

$ sudo ufw allow 53/tcp
$ sudo ufw allow 43/tcp
$ sudo ufw reload

Open DNS Ports on FirewallD Firewall

On RHEL-based distributions, you need to open ports 53 & 43 on the Firewalld firewall by running the commands below.

$ sudo firewall-cmd --add-port=53/tcp --permanent
$ sudo firewall-cmd --add-port=43/tcp --permanent
$ sudo firewall-cmd --reload

It’s our hope that you now have an idea about the ‘temporary failure in name resolution‘ error and how you can go about fixing it in a few simple steps. As always, your feedback is much appreciated.

James Kiarie
This is James, a certified Linux administrator and a tech enthusiast who loves keeping in touch with emerging trends in the tech world. When I'm not running commands on the terminal, I'm taking listening to some cool music. taking a casual stroll or watching a nice movie.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

6 thoughts on “How to Resolve “Temporary failure in name resolution” Issue”

  1. The advice about editing /etc/resolv.conf is fairly wrong for Ubuntu since maybe 16.04 or earlier. systemd-resolved takes over and will overwrite your changes.

    You can either edit /etc/systemd/resolved.conf to include a [Resolve] section that contains, for example, DNS=8.8.8.8 and FallbackDNS=4.4.4.4 entries; or as I do, completely remove systemd-resolved, because I don’t find it to do anything more useful than the C library name resolution system, and it is definitely more complicated and failure-prone.

    Reply
  2. I still haven’t got the solution, as it is saying ufw not found.

    Like ufw firewall isn’t on my computer.

    What to do now someone please help.

    Reply
  3. I am running Linux mint 19 with all current updates as of March 6, 2021. The file /etc/resolv.conf is a link to the same file name in /run/resolvconf.

    That file says in all caps on a comment line: Do not edit this file by hand – – your changes will be overwritten

    What now for resolving the problem?

    I did this again because I do not know if I succeeded the first time in posting this.

    Reply

Leave a Reply to Howard Rutiezer Cancel reply

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.