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:-
sudo echo "yourhostname" > /etc/hostname sudo hostname -F /etc/hostname
sudo nano /etc/hostname
sudo nano /etc/hosts
You need to change the corresponding text just after 127.0.1.1 to “yourhostname”.
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.
This will solve the issue.