Ubuntu: sudo: unable to resolve host : Error

It becomes irritating when cloning a server only to get the hostname error again.

root@server1:~$ sudo apt update
sudo: unable to resolve host server1

This happens because the server is unable to determine the hostname of the server

Resolution includes looking at 2 files.

/etc/hostname

/etc/hosts

In /etc/hostname ensure the hostname of your server is updated, matches the current hostname of the server you are using.

sudo nano /etc/hostname

*edit file to hostname

server1

Ctrl + x  and y to save

and in /etc/hosts

sudo nano /etc/hosts

*edit file where server1 is your hostname

127.0.0.1 localhost
127.0.0.1 server1

again to exit, ctrl + x then y

Leave a Reply

Your email address will not be published. Required fields are marked *