sudo: unable to resolve host

This error generally occurs when, you launched an instance in Virtual Private Network on Amazon Web Services. Whenever you use sudo with any command, you will get something like this:

sudo: unable to resolve host <host_ip>


<host_ip> will be in the format ip-xx-xx-xx-xx

To solve this error, you just need to edit your /etc/hosts file. For it, open the file in your favorite editor. Here I am using vim.

sudo vim /etc/hosts


Now, add the following stuff in the opened file:

127.0.0.1 localhost.localdomain localhost
127.0.1.1 <host_ip>


Save the file. And restart the instance (if necessary). You are done!

Leave a Reply

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