1

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:

127.0.0.1 kaushal
120.0.0.1 localhost.localdomain localhost
127.0.0.1 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:

127.0.0.1 kaushal
120.0.0.1 localhost.localdomain localhost
127.0.0.1 localhost.com

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

sudo: unable to resolve host 127.0.0.1kaushal

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 127.0.0.1 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 : 127.0.0.1 localhost.localdomain localhost comes first then 127.0.1.1 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 127.0.0.1 kaushal...it's supposed to be 127.0.1.1 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 "127.0.0.1 kaushal" so I guess that was the problem. – Kaushal Suthar Jun 11 '16 at 20:42
3

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

1

I will answer your question specifically
In your /etc/hosts for localhost change 127.0.0.1 kaushal to
127.0.1.1 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.