How to Fix – Sudo unable to resolve host in Ubuntu?

If you getting an error “Sudo unable to resolve host” while executing sudo command in Ubuntu, then here’s how you can fix the issue.

Below is the snapshot of the error:

ubuntu@test$ sudo su -
sudo: unable to resolve host (test)


Check if /etc/hostname contains the correct hostname of your machine.

$ vi /etc/hostname

Check if /etc/hosts file contains the below line with hostname appended at the end.

$ vim /etc/hosts                localhost.localdomain                localhost             hostname_of_machine

If the above two files contain the correct hostname of your machine, then sudo will resolve properly.

Updated on September 2, 2017

Was this article helpful?

Related Articles


Leave a Comment