Error: Unable to Resolve Hostname

When you are getting error “Unable to resolve hostname” in your VPS even after changing the hostname from command line, you can solve it by simply restarting the server.

How to change Hostname?

Use the following commands:-

Change hostname:

sudo echo "yourhostname" > /etc/hostname
sudo hostname -F /etc/hostname

Check hostname:

sudo nano /etc/hostname

Edit Hostfile:

sudo nano /etc/hosts

You need to change the corresponding text just after to “yourhostname”.

Final Check:


If the output gives “yourhostname”. you are done.


Whenever you run a command using sudo you are getting an error which displays, “Unable to resolve hostname ..“.


Restart VPS from command line by typing the following command.

sudo reboot

This will solve the issue.

Leave a Reply

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