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

Updated on September 2, 2017

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)

Solution:

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
127.0.0.0                localhost.localdomain                localhost             hostname_of_machine

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

Was this article helpful?

Related Articles

Comments Leave a Comment

Leave a Comment