Ever faced with an error like this? Unable to resolve host is a very common error in Linux systems.
Here’s how you can solve it.
Step 1: Log into the system as the root user.
Step 2: Two things need to be checked. Let’s assume that the machine name is machine1.
The first thing to be checked here is if the entry in the hostname file of the machine is correct.
This can be checked with the following command:
sudo nano /etc/hostname
If the machine name machine1 is not there in this file, enter it here.
Step 3: Check the hosts file.
The file /etc/hosts is usually the commonplace missing the machine name in most of the cases. Open and check this file if the machine1 is entered hereafter the localhost line.
sudo nano /etc/hosts
The final file should look something like this:
127.0.0.1 localhost.localdomain localhost 127.0.1.1 machine1
The hostname will not change until you reboot. So if you have made any changes as said above, restart the system with this command.
sudo systemctl restart
This should remove the error finally.