Introduction
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.
Prerequisites
- 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:
ping phoenixnap.com
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:
nameserver 8.8.8.8
If you do not have a nameserver listed in the file, add at least one. 8.8.8.8
and 8.8.4.4
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:
ping phoenixnap.com
If you see the ping command transmitting and receiving data, your DNS server is working properly.
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.
ping phoenixnap.com
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
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
.
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.
ping phoenixnap.com
Note: Check out our post on DNS troubleshooting as well.
Conclusion
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.
原创文章,作者:carmelaweatherly,如若转载,请注明出处:https://blog.ytso.com/224578.html