6

I get a message saying: sudo: unable to resolve host (myhostname) each time I write a command.

My hostname does not contain any capital letters or numbers.

6
  • 1
    Does /etc/hosts contain an entry like 127.0.1.1 myhostname? Commented Apr 7, 2017 at 21:11
  • Thank you, i added myhostname in this file and the message went disappered. Commented Apr 7, 2017 at 22:53
  • I have another problem it concerns the Wifi. i can't really connect to my router, i added my connection information in /etc/wpa_supplicant/wpa_supplicant.conf and changed /etc/network/interfaces. Commented Apr 7, 2017 at 22:57
  • Also, the wifi icon mentions Wlan0 " No wifi interfaces found" Commented Apr 7, 2017 at 22:58
  • "changed /etc/network/interfaces" is probably your problem DO NOT MODIFY See How do I set up networking/WiFi/Static IP Also if you changed your hostname using raspi-config you would not probably have had the problem you originally posted. Commented Apr 7, 2017 at 23:46

1 Answer 1

6

Sometimes, even if you've changed the host name via raspi-config, the settings don't stick. To make it permanent:

sudo nano /etc/hosts 

and change the line that says

127.0.1.1 raspberrypi 

to

127.0.1.1 myhostname 

assuming that myhostname is the name you want to use. Save, exit and reboot, and the message will go away.

3
  • Isn't the localhost IP 127.0.0.1? Commented May 25, 2020 at 12:41
  • 1
    It's complicated …. But this issue appears to be resolved in Raspbian. Commented May 25, 2020 at 12:51
  • This fixed my issue! Thanks! Commented Nov 21, 2021 at 14:49

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.