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.
- 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.
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.
184.108.40.206 are the popular nameservers owned by Google, but you can add any functional DNS server to this list.
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.
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.
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.
Open the ports in firewalld
sudo firewall-cmd --add-port=43/tcp --permanent
firewalld outputs the word
Repeat the command for port 53.
sudo firewall-cmd --add-port=53/tcp --permanent
Reload the firewall.
sudo firewall-cmd --reload
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.