Velvet Star Monitor

Standout celebrity highlights with iconic style.

updates

how do i fix sudo: unable to resolve host raspberrypi4: Name or service not known

Writer Sophia Terry

i have been running into this problem that makes me unable to use sudo for the past while on my raspberry pi 4 but when i look in the /etc/hosts folder i see this

192.168.0.22 localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
192.168.0.22 hostname

and the /etc/hostname says hostname

by the way my host name is ------------ but i'll replace it with hostname

1

1 Answer

Have you manually edited your /etc/hosts file?

It should look more list this:

127.0.0.1 localhost
::1 localhost ip6-localhost ip6-loopback
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

Localhost is usually 127.0.0.1 and many services require this to function properly.

Restore it to default and add a line at the bottom 192.168.0.22 <your.hostname>

For a more detailed explanation of how address resolution works in Linux, start with man 5 nsswitch.conf

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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