Sometimes you may get an error saying ‘temporary failure in name resolution’ when you try to ping a website, or update package or system, or run a command that requires internet connection with another system. In this article, we will understand what this error means and how to fix it.
How to Fix Temporary Failure in Name Resolution Issue in Linux
Here is an example of error message in Linux.
$ ping google.com ping: 54.43.32.21: Temporary failure in name resolution
The above error means that your DNS server is unable to resolve domain names to their respective IP addresses. This can be a big problem as it can stop you from updating, upgrading or even installing packages on your system. We will look at a couple of reasons for this.
1. Missing or Wrongly Configured resolv.conf file
The file /etc/resolv.conf is the configuration file for DNS resolution. It contains a list of DNS entries to help you resolve domain names to IP addresses. Open it in a text editor.
$ sudo vi /etc/resolv.conf
If you don’t find this file on your system, create a new one with the above command, and append the following line to it. It will add the DNS server address of Google’s public DNS server.
nameserver 8.8.8.8
Save and close the file. Run the following command to restart systemd-resolved service.
$ sudo systemctl restart systemd-resolved.service
Now try pinging google.com.
$ ping google.com
2. Firewall Restrictions
Sometimes firewall restrictions may be preventing your system from running DNS queries. So check if your port 53 and 43 are open. Port 53 is used for domain name resolution (DNS) and port 43 is used for whois lookup. If they are closed then run the following commands, depending on your firewall system, to open the ports.
For UFW firewall (Ubuntu / Debian and Mint)
$ sudo ufw allow 53/tcp $ sudo ufw allow 43/tcp $ sudo ufw reload
For firewalld (RHEL / CentOS / Fedora)
$ sudo firewall-cmd --add-port=53/tcp --permanent $ sudo firewall-cmd --add-port=43/tcp --permanent $ sudo firewall-cmd --reload
In this short article, we have learnt how to fix ‘temporary failure in name resolution’ error in Linux.
Also read:
How to Add Route in Linux
How to Change Root Password in CentOS, RHEL, Fedora
How to Ping Specific Port in Linux
How to Count Number of Files in Directory in Linux
How to Increase Your Security on Internet
Related posts:
Sreeram has more than 10 years of experience in web development, Python, Linux, SQL and database programming.