Troubleshooting the "Temporary Failure in Name Resolution" Error in Linux
Linux users may encounter the "Temporary failure in name resolution" error while trying to access websites or execute networking commands. This error indicates that the system is unable to translate a domain name into its corresponding IP address. Several factors can contribute to this error, including network connectivity issues, incorrect configuration of the resolv.conf file, and firewall restrictions. In this guide, we will explore the common causes of this error and provide solutions to help you resolve the issue.
Common Causes and SolutionsSlow or No Internet Connection
Before troubleshooting further, it's essential to check your internet connectivity. A slow or disconnected internet connection may be the root cause of the "Temporary failure in name resolution" error.
Confirm that your system has a stable and working internet connection. If your internet connection is slow or disconnected, try to fix the connectivity issue before proceeding.Badly Configured resolv.conf File
The resolv.conf file is responsible for configuring DNS servers on Linux systems. If this file is not set up correctly, the system may fail to resolve domain names.
Start by opening the resolv.conf file in a text editor such as nano:
sudo nano /etc/resolv.conf
Ensure that at least one nameserver is defined in the resolv.conf file. A valid nameserver entry should look like this:
If there is no nameserver defined in the file, add one. Some well-known nameservers owned by Google are
18.104.22.168. After making the changes, save the file and restart the DNS resolver service:
sudo systemctl restart systemd-resolved.service
Verify that the DNS server is working correctly by pinging a website:
If communication is established with the website, the DNS server is working correctly.
Misconfigured resolv.conf File Permissions
If the resolv.conf file contains valid DNS servers, but the error persists, it may be due to incorrect file permissions.
Change the ownership of the resolv.conf file to the root user:
sudo chown root:root /etc/resolv.conf
Modify the file permissions to allow all users on the system to read the file:
sudo chmod 644 /etc/resolv.conf
Try pinging a website again to check if the issue is resolved.Firewall Restrictions
Firewall restrictions may block access to necessary ports, causing the error. Ports 43 (used for whois lookup) and 53 (used for domain name resolution) are essential for DNS queries.
Open the necessary ports in the Uncomplicated Firewall (UFW) by running the following commands:
sudo ufw allow 43/tcp sudo ufw allow 53/tcp
Note: If UFW is not enabled by default, enable it using
sudo ufw enable.
After allowing the ports, reload the UFW firewall to apply the changes:
sudo ufw reload
The "Temporary failure in name resolution" error can be caused by various factors, including internet connectivity issues, misconfiguration of the resolv.conf file, and firewall restrictions. By addressing these common causes, you can resolve the error and successfully access websites and execute networking commands on your Linux system.