Linux Commands

How to Resolve the “Temporary Failure in Name Resolution” Error

Encountering the “Temporary failure in name resolution” error shows that Linux systems cannot translate a website name into IP address. While a lost internet connection may be a reason, there are several other factors that could cause this error. This tutorial is presented to help you troubleshoot and resolve this error.

Prerequisites

To proceed with the solutions outlined below, ensure you have sudo or root privileges and a functional internet connection.

  • User must have sudo or root privileges
  • Stable and working network connectivity

What is the Temporary Failure in Name Resolution Error

When we access a website, our system browser sends a request to a DNS server that will translate the domain name into an IP address. This IP address will connect the website’s server and load the content. If the DNS server fails to provide the IP address, the “Temporary failure in name resolution” error message appears.

For example, if we ping the website from a system, you may experience the following error:

ping linuxhint.com

Here the system failed to connect to the DNS server hence resulting in error.

The main three main reason why this error occur includes:

  1. Slow or No Internet Connection
  2. Badly Configured resolv.conf File
    • Misconfigured resolv.conf File Permissions
  3. Firewall Restrictions
    • Open the Ports in UFW Firewall

Solution 1: Slow or No Internet Connection

The first solution to resolve the error is straightforward as the user can check the internet connectivity on the system. If the internet is slow or not connected, you may experience this error.

Solution 2: Badly Configured resolv.conf File

The resolv.conf file sets up the DNS servers on Linux. Open the resolv configuration file in nano editor:

sudo nano /etc/resolv.conf

Make sure at least one nameserver is present inside the resolv.conf file. The nameserver looks like this:

nameserver 8.8.8.8

Here in our case nameserver is:

nameserver 127.0.0.53

If no nameserver is present in the system. Defined any of the nameservers. Some of the well-known name servers owned by Google are 8.8.8.8 and 8.8.4.4. By editing the resolv.conf file any of the nameserver can be defined.

Save the file and restart DNS service:

sudo systemctl restart systemd-resolved.service

If the DNS server is restarted successfully no output will be returned.

You can also verify the DNS server by again pinging a website:

ping linuxhint.com

If communication is established with the website this means the DNS server is now working.

2.1. Misconfigured resolv.conf File Permissions

In some cases, despite the proper DNS server defined inside the resolv.conf file, the error persists. This may be due to file permission missing. Change the ownership access to root user by running the given command:

sudo chown root:root /etc/resolv.conf

Run given command to give permission to each user to allow them to modify the resolv.conf file:

sudo chmod 644 /etc/resolv.conf

Now we will again ping the website.

ping linuxhint.com

If the error is due to wrong permission, the above commands will solve it.

Solution 3: Firewall Restrictions

Another reason for the “Temporary failure in name resolution” error is due to a firewall blocking access to the necessary ports, which includes port 43 used for whois lookup and port 53 used for domain name resolution.

3.1. Open the Ports in UFW Firewall

If the error is caused by blocking of port 43, run the below given command to allows traffic on this port:

sudo ufw allow 43/tcp

The Uncomplicated Firewall (UFW) confirms that rules have been successfully updated.

Similarly, we can also allow the permission for port 53 using:

sudo ufw allow 53/tcp

Note: Sometime our UFW firewall is not enabled by default, so to enable it, use:

sudo ufw enable

Now, reload the UFW firewall to apply the changes:

sudo ufw reload

Conclusion

The error “Temporary failure in name resolution” can occur due to no internet connection, missing DNS nameserver or resolv.conf file permissions or firewall restriction. Main solution to this problem is to fix the internet problem, allow the resolv.conf file access to all users or unblock the UFW firewall protection at port 43 and port 53.

About the author

Kashif

I am an Electrical Engineer. I love to write about electronics. I am passionate about writing and sharing new ideas related to emerging technologies in the field of electronics.