Yes, Might be duplicate of following links Tried both links solutions but didn't worked for me.

  1. Error message when I run sudo: unable to resolve host (none)

  2. sudo: unable to resolve host ubuntu-server

Following is my /etc/hosts output: kaushal localhost.localdomain localhost localhost.com

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Following is my /etc/hostname output: kaushal localhost.localdomain localhost localhost.com

Every time when I write command sudo apt-get update I get following error message.

sudo: unable to resolve host

Also in my terminal I get kaushal@127:~$ as following screenshot. enter image description here

It was not like that before.

All this started happening after I change my username from

All Setting >  Details > Device name

Any suggestion what's wrong with my machine?? How can I resolve this problem. Let me know if you want more details.

  • Have you tried deleting the line localhost.com , save changes and then reboot your machine? – Dominic Motuka Jun 11 '16 at 20:21
  • Also try to interchange the lines such like : localhost.localdomain localhost comes first then kaushal where kaushal is your machine name. – Dominic Motuka Jun 11 '16 at 20:32
  • Yes I did that too. – Kaushal Suthar Jun 11 '16 at 20:37
  • Suthar there's a typo in kaushal...it's supposed to be kaushal – Dominic Motuka Jun 11 '16 at 20:40
  • Maybe, I've checked my hostname file and now it has only my name. There is nothing like " kaushal" so I guess that was the problem. – Kaushal Suthar Jun 11 '16 at 20:42

I solved the problem by going to
All Setting > Details > Device Name
changed the device name to kaushal
Just make sure that your /etc/hostname file has only your machine name.For my case it was kaushal


I will answer your question specifically
In your /etc/hosts for localhost change kaushal to localhost localhost.localdomain kaushal

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.