I am having difficulty in ssh-ing into Raspberry Pis via their mDNS (avhai / zeroconf) .local host names.

After reboot I can ssh into a pi as expected:

$ ssh user@raspberrypi.local

However after a period of time (it seems to be a day or two - but I've not measured it accurately) I can no-longer access the Pi's via their ".local" URI (ssh, ping, HTTP access, etc. all fail to connect); but I can still access the pi's via their IP addresses (e.g. $ ssh user@ A reboot of the Pi restores the previous mDNS .local host name.

This effects multiple Pi's (both Pi 3 & 4); and it happens with both WiFi and ethernet connections.

I'm running Raspbian / Raspberry Pi OS on the Pi's; and networking via OpenWRT on Linksys hardware.

Any ideas?

  • 1
    Rather than reboot try sudo systemctl restart avahi-daemon. – Dougie Aug 5 at 19:20
  • That works perfectly @Dougie… Still not sure why avahi is falling over – but restarting it is a much preferable fix than a full reboot. Thankyou! – AJ Poulter Aug 10 at 13:32

Occasionally caching prevents Zero-conf resolution and the only cure I have found is to restart all network devices although pinging sometimes refreshes the arp cache.

You may be interested in the following script I use. This falls back to a reserved IP Address if Zero-conf fails.

# script to start ssh connection to Pi
# If not found use default ADDRESS
# 2019-07-30

ADDRESS=""     # WiFi
ADDRESS2=""    # Ethernet

ping -c1 $TARGET > /dev/null 2>&1
if [ $rc1 -gt 0 ]; then
    echo "Can't ping $TARGET"
    ping -c1 $TARGET > /dev/null 2>&1
    if [ $rc2 -gt 0 ]; then

if [ $# -eq 0 ] ; then

PS1='\h:\W \u\$ '
| improve this answer | |

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.