0

I have a headless Raspberry Pi set up in a WiFi network and need to connect to it using its hostname.

On some computers in the same network this works just as intended with the command ssh pi@raspberrypi. But on other devices, the hostname is not recognized. I also can not ping the Raspberry Pi from those devices. Using the IP instead of the hostname works on all devices and for both ping and ssh.

Why does one device get a response from raspberrypi while others do not? Is this actually a problem with the Pi or with the router?

4
  • Try ssh [email protected] The "dot-local" suffix is the standard for "avahi-daemon" used by recent versions of the Raspberry Pi OS.
    – user68186
    Jul 27, 2022 at 18:54
  • @user68186 unfortunately, ssh [email protected] and ping raspberrypi.local don't work either. Another fun fact: the hostname used to work for me, but my colleague complained that it didn't work for him. Now (a few months later) it's the other way around: it works for him but not for me. We both have notebooks by Lenovo running Windows 10...
    – Sim Son
    Jul 27, 2022 at 19:06
  • Something has gone wrong. I have no idea if the problem is on the Windows 10 side or the Pi side. Try the Windows CMD net view | find /i "raspberrypi" and see if it turns up. If nothing shows, try rebooting the Pi.
    – user68186
    Jul 27, 2022 at 19:21
  • I have a Windows 10 laptop, a Manjaro mini pc, and a Comcast wifi router. Going from Windows to Manjaro, I can use either hostname or hostname.local. However, sometimes it will only work with one or the other.
    – NomadMaker
    Aug 29, 2022 at 1:05

1 Answer 1

2

Windows is always going to be an outlier; I can't help you with your Windows issues, except to offer this. I can share some general information relevant to your RPi that might help:

Wrt your RPi, there are two things to check/verify:

  1. /etc/hostname Under most circumastances, it should have a single line with the name of the host; e.g.:
$ cat /etc/hostname
raspberrypi3b
  1. /etc/hosts
$ cat /etc/hosts
127.0.0.1   localhost
::1     localhost ip6-localhost ip6-loopback
ff02::1     ip6-allnodes
ff02::2     ip6-allrouters

127.0.1.1   raspberrypi3b raspberrypi3b.local

Note the last line in particular: 127.0.1.1. At least one entry (raspberrypi3b) must be included for mdns to work consistently. I have added a second name (raspberrypi3b.local) as a contingency. There's some decent documentation on this from Debian. Raspberry Pi also has some documentation, but it must be carefully parsed as it tends to lead some readers astray, and they have an odd attitude about this - at least to my way of thinking.

Just to make sure there's no confusion, the hostname I've used (raspberry3b) is one I chose. You are free to choose your own!

Once you get your Windows hosts configured to support mDNS (aka avahi, aka zero configuration networking), and verify the 2 settings above, things should fall into place.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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