How to Resolve the "Temporary failure in name resolution" Error

October 6, 2021


The "Temporary failure in name resolution" error occurs when the system cannot translate a website name into an IP address. While the error sometimes appears due to a lost internet connection, there are multiple reasons why it may show up on your system.

This tutorial will guide you through troubleshooting and fixing the "Temporary failure in name resolution" error.

How to resolve the "Temporary failure in name resolution" error


  • Sudo or root privileges
  • A working internet connection

The error appears when a user attempts to communicate with a website using a command such as ping:


The system cannot communicate with the DNS server and returns the error.

Pinging a website unsuccessfully.

The most common cause of this error are the resolv.conf network configuration file and a misconfigured firewall. The steps to fix the error in both cases are given below.

Method 1: Badly Configured resolv.conf File

resolv.conf is a file for configuring DNS servers on Linux systems.

To start, open the file in a text editor such as nano.

sudo nano /etc/resolv.conf

Make sure the resolv.conf file contains at least one nameserver. The lines listing nameservers should look like this:


If you do not have a nameserver listed in the file, add at least one. and are the popular nameservers owned by Google, but you can add any functional DNS server to this list.

The /etc/resolv.conf file in nano editor.

Save the file and exit.

Then, restart the DNS resolver service.

sudo systemctl restart systemd-resolved.service

If successful, the command above returns no output. Test that your new nameservers are correctly configured by pinging a website:


If you see the ping command transmitting and receiving data, your DNS server is working properly.

Successfully pinging a website.

Misconfigured Permissions

If your resolv.conf file contains valid DNS servers, but the error persists, it may be due to misconfigured file permissions. Change ownership of the file to the root user with the following command:

sudo chown root:root /etc/resolv.conf

Modify the user permissions to allow everybody on the system to read the file:

sudo chmod 644 /etc/resolv.conf

Ping a website again.


If wrong file permissions caused the error, the commands above successfully resolve it.

Method 2: Firewall Restrictions

Another reason for the "Temporary failure in name resolution" error may be a firewall blocking one or both of the following ports:

  • port 43, used for whois lookup
  • port 53, used for domain name resolution

Open the ports in UFW Firewall

Type the following command to allow traffic on port 43 using UFW firewall:

sudo ufw allow 43/tcp

UFW confirms the rule is successfully updated.

Allowing port 43 in UFW.

Repeat the command for port 53.

sudo ufw allow 53/tcp

Reload UFW with the following command:

sudo ufw reload

The output confirms the operation was successful.

Reloading UFW firewall.

Open the ports in firewalld

Some Linux distributions such as CentOS use firewalld as their default firewall. The syntax to open port 43 in firewalld is:

sudo firewall-cmd --add-port=43/tcp --permanent

firewalld outputs the word success.

Allowing port 43 in firewalld.

Repeat the command for port 53.

sudo firewall-cmd --add-port=53/tcp --permanent

Reload the firewall.

sudo firewall-cmd --reload
Reloading firewalld firewall.

Test the connection by pinging a website.


Note: Check out our post on DNS troubleshooting as well.


This article provided ways to troubleshoot and fix the "Temporary failure in name resolution" error on Linux. To learn more about diagnosing DNS-related problems, read How to Use Linux dig Command.

Was this article helpful?
Marko Aleksic
Marko Aleksić is a Technical Writer at phoenixNAP. His innate curiosity regarding all things IT, combined with over a decade long background in writing, teaching and working in IT-related fields, led him to technical writing, where he has an opportunity to employ his skills and make technology less daunting to everyone.
Next you should read
How to Disable or Turn Off Firewalld on CentOS 7
August 15, 2019

There are situations when admins need to disable firewalld for testing or switching to another firewall tool, like iptables. This tutorial will show you how to disable and stop the firewall on CentOS 7.
Read more
How to Enable/Disable UFW Firewall on Ubuntu 18.04
August 18, 2019

UFW firewall is an easy to use solution for server firewall settings management. This tutorial shows you how to disable and enable an Ubuntu UFW firewall using the command line.
Read more
How to set DNS Nameserver on Ubuntu 20.04
May 18, 2021

By default, most networks are configured to work with DNS servers supplied by the internet service provider. This tutorial will show you how to change DNS nameservers on your Ubuntu machine.
Read more
What is a Domain Name System (DNS) & How Does it Work?
October 6, 2021

DNS first emerged in the early 1980s. It represents a system of interconnected servers that store registered domain names and IP addresses.
Read more