42

My Raspberry Pi is not discoverable via its hostname in my LAN.

I have a couple of other Ubuntu machines in the LAN, and they are all pingable via their hostnames.

On my Raspberry Pi:

pi@raspberrypi ~ $ hostname
raspberrypi

On another machine in the same LAN:

ping raspberrypi
ping: unknown host raspberrypi
  • Duplicate question: unix.stackexchange.com/questions/77189/…. Closed as off-topic as this is a general Linux networking issue, not related to the Raspberry Pi. – Jivings Jun 7 '13 at 6:54
  • Why is it not releated to Raspberry Pi if I have an Odroid with Ubuntu 14.04, a MÎNIX with Debian and a virtual PC I boot with Ubuntu 15.10 in the same network without this issue? Only on my Raspberry Pi 2 with Raspian I have this issue since I upgraded to Jessie. – Shy Robbiani Jan 18 '16 at 14:24
  • just as a side note, this will probably not affect most people out there reading this, but some people might have avahi installed and wondering why it's not working for them -> one possibility is that your network configuration doesn't support multicast. – Lukas1 Jul 4 '16 at 5:41
  • @clamp Shouldn't it be ping raspberrypi.local, I think that the .local part is vital – Linus Unnebäck Jan 22 '18 at 11:00
15

Have you tried doing a ping test using the IP address? If that works your problem is usually with resolving the name to an IP address.

There are many ways to fix this. You could

  • Add an entry to your /etc/hosts file with your pi's static-ip and hostname
  • Add a static reservation to your dhcp server and add a record to your local dns server (If your router supports it)
  • Run a service like NIS, Avahi or Samba on your pi. The choice depends on the OS you are pinging from.
    • Windows clients will benefit from installing Samba.
    • OS/X clients will benefit from Avahi or Samba.
    • Linux clients will probably benefit from NIS or Samba depending on what is installed. I guess the Ubuntu computers use samba to advertise their hostnames.
  • yeah pinging via the ip is fine, but it does not have a static ip address. – clamp May 26 '13 at 21:20
  • What OS are you pinging the pi and ubuntu boxes from? If you are on a linux machine could you see what the value of hosts: is in your /etc/nsswitch.conf? – Surajram Kumaravel May 26 '13 at 21:22
  • 1
    Thanks. I've solved mine via Samba. Samba will be useful at some point as its a bit easier to access files this way – fedmich Mar 14 '16 at 16:02
70

You have to use avahi-daemon (zeroconf) if you want to connect via a hostname instead of an IP address. From the Raspberry Pi documentation on RPi Advanced Setup:

Install avahi with the following commands on the Raspberry Pi:

sudo apt-get install avahi-daemon

Update boot startup for avahi-daemon

sudo insserv avahi-daemon

Apply the new configuration with:

sudo /etc/init.d/avahi-daemon restart

The Raspberry Pi should now be addressable from other machines as raspberrypi.local, for example: ssh pi@raspberrypi.local or http://raspberrypi.local if you have HTTP service installed.

If you couldn't connect from Windows PCs via SSH probably you haven't installed the Bonjour service.

Get Bonjour for Windows: Download Bonjour Print Services for Windows v2.0.2. Just install it.

  • 13
    This should be the selected answer – Sudar Aug 10 '13 at 15:43
  • 3
    Silly, just to let others know: in my case my home router (Pirelli Centro Grande) is handling dhcp for my LAN. I never had ssh or network issues with Raspian nor any other Linux in my LAN until I upgraded to Raspian Jessie. This automatically installed dhcpd and avahi. I had to remove both, avahi-daemon and isc-dhcpd-server to avoid dhcp and name server conflicts with my router. Now my Raspberry is available by its name again. – Shy Robbiani Jan 18 '16 at 16:16
  • 1
    I had the same issue as @ShyRobbiani - disabling/removing avahi-daemon caused my rpi to be picked up on my home network as it did pre-Jessie. – keithl8041 Jan 1 '17 at 18:54
  • 2
    'insserv' isn't available on my raspbian... ? – copa017 Oct 18 '17 at 15:01
  • 2
    @copa017 Not here either on my Raspbian Lite at least, but just sudo apt-get install insserv. Otherwise follow the instructions above. Tested and worked for me! – Jonas Dec 26 '17 at 19:53

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