generalveers
Posts: 43
Joined: Fri Aug 21, 2020 11:14 pm

Hostnames don't resolve until reboot

Sun May 09, 2021 6:29 pm

I'm running two Pis (on Buster) in my house, each of which has a static IP and a unique hostname.

The problem is that I can only sometimes connect by using [hostname].local. For no reason I can discern, the Pis will randomly stop responding to the hostnames and only respond to the IP address.

When I reboot, the hostname works again...but eventually stops responding to VNC, SSH, ping, etc.

One Pi is connected by ethernet, the other by wifi. Seems to make no difference -- they both suffer from this problem.

I confirmed that avahi-daemon is running and also tried editing /etc/hosts, but no help.

Obviously, this isn't an emergency or even a big deal -- I can still connect just fine through the IP addresses. But it's weird! So I'm trying to figure it out.

Any thoughts?

epoch1970
Posts: 6497
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Hostnames don't resolve until reboot

Sun May 09, 2021 7:42 pm

Which OS is it ?
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

hal8000
Posts: 262
Joined: Fri Oct 04, 2013 5:22 pm

Re: Hostnames don't resolve until reboot

Sun May 09, 2021 7:48 pm

What host system are you trying to communicate with your RPi's?

If its windows you need to modify the windows host file which will be somewhere like
C:\Windows\System32\drivers\etc


If you're on linux or FreeBSD then its in /etc/hosts

copy and paste your hosts file on your next post so someone can help you

generalveers
Posts: 43
Joined: Fri Aug 21, 2020 11:14 pm

Re: Hostnames don't resolve until reboot

Sun May 09, 2021 8:49 pm

epoch1970 wrote:
Sun May 09, 2021 7:42 pm
Which OS is it ?
I'm on either iOS or macOS.

The weirdest thing is that it works on reboot, but then eventually stops. I can't figure out if it's a Pi problem or something with my router.

User avatar
thagrol
Posts: 4974
Joined: Fri Jan 13, 2012 4:41 pm
Location: Darkest Somerset, UK
Contact: Website

Re: Hostnames don't resolve until reboot

Sun May 09, 2021 9:45 pm

hal8000 wrote:
Sun May 09, 2021 7:48 pm
What host system are you trying to communicate with your RPi's?

If its windows you need to modify the windows host file which will be somewhere like
C:\Windows\System32\drivers\etc


If you're on linux or FreeBSD then its in /etc/hosts

copy and paste your hosts file on your next post so someone can help you
Nope. Not when using avahi/mDNS. Those don't use the hosts file.
I'm a volunteer. Take me for granted or abuse my support and I will walk away

All advice given is based on my experience. it worked for me, it may not work for you.
Need help? https://github.com/thagrol/Guides

epoch1970
Posts: 6497
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Hostnames don't resolve until reboot

Sun May 09, 2021 10:24 pm

generalveers wrote:
Sun May 09, 2021 8:49 pm
epoch1970 wrote:
Sun May 09, 2021 7:42 pm
Which OS is it ?
I'm on either iOS or macOS.

The weirdest thing is that it works on reboot, but then eventually stops. I can't figure out if it's a Pi problem or something with my router.
I meant, are you running raspios? Publishing the name and address can be achieved in various ways under Linux. OTOH I’d say the current raspios release uses avahi, but I’m not certain a separate process is spawned to publish the address. If it’s a separate process, it’s not impossible it dies.
The normal reason for the name to cease being resolved is for the publication/process to be stopped because the network interface went down.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

generalveers
Posts: 43
Joined: Fri Aug 21, 2020 11:14 pm

Re: Hostnames don't resolve until reboot

Sun May 09, 2021 11:57 pm

epoch1970 wrote:
Sun May 09, 2021 10:24 pm
generalveers wrote:
Sun May 09, 2021 8:49 pm
epoch1970 wrote:
Sun May 09, 2021 7:42 pm
Which OS is it ?
I'm on either iOS or macOS.

The weirdest thing is that it works on reboot, but then eventually stops. I can't figure out if it's a Pi problem or something with my router.
I meant, are you running raspios? Publishing the name and address can be achieved in various ways under Linux. OTOH I’d say the current raspios release uses avahi, but I’m not certain a separate process is spawned to publish the address. If it’s a separate process, it’s not impossible it dies.
The normal reason for the name to cease being resolved is for the publication/process to be stopped because the network interface went down.
Oh! Oops, sorry! Running Raspian Buster in both cases. What you say makes a lot of sense. I wonder what could be taking down the network interface and why.

RonR
Posts: 2181
Joined: Tue Apr 12, 2016 10:29 pm
Location: US

Re: Hostnames don't resolve until reboot

Mon May 10, 2021 12:22 am

I done use *.local, so I'm shooting from the hip here.

The avahi-daemon incorporates the assigned hostname in its process name display:

Code: Select all

root@raspberrypi:~# ps ax | grep avahi
  399 ?        Ss     0:00 avahi-daemon: running [raspberrypi-2.local]
These hostnames work as expected between two Raspberry Pi 4B's running Buster here. If I reboot either Raspberry Pi, however, the hostname frequently changes. Could it be this is what's happening to you? When you get no response, go to that device and check it's process name and see if it's changed on you. Surely there must be a way to get consistent naming, but this is not an area I'm familiar with.

generalveers
Posts: 43
Joined: Fri Aug 21, 2020 11:14 pm

Re: Hostnames don't resolve until reboot

Mon May 10, 2021 1:40 am

RonR wrote:
Mon May 10, 2021 12:22 am
I done use *.local, so I'm shooting from the hip here.

The avahi-daemon incorporates the assigned hostname in its process name display:

Code: Select all

root@raspberrypi:~# ps ax | grep avahi
  399 ?        Ss     0:00 avahi-daemon: running [raspberrypi-2.local]
These hostnames work as expected between two Raspberry Pi 4B's running Buster here. If I reboot either Raspberry Pi, however, the hostname frequently changes. Could it be this is what's happening to you? When you get no response, go to that device and check it's process name and see if it's changed on you. Surely there must be a way to get consistent naming, but this is not an area I'm familiar with.
Oh, wow, yeah -- when I try that, I get the proper hostname, but with a number appended. So, [hostname]-3.local, for example.

That's a good clue. Thanks for the suggestion!

MiscBits
Posts: 249
Joined: Wed Jan 27, 2021 12:48 pm

Re: Hostnames don't resolve until reboot

Mon May 10, 2021 2:18 am

Are you running 2.4 and 5Ghz WiFi by any chance?

I've seen issues where some home routers 'forget' device names on the other network. BT have just been called out on this (see here) and I know tp-link have similar issues.

I'm pretty sure the older Airports (flat pizza-box style) APs from Apple have the same glitch but not 100% convinced I've tracked it down to the APs or an IGMP snooping issue.

It may be worth turning IGMP snooping off - sorted out a HP printer 'dropping off' the network here.
Is a computer language with goto's totally Wirth-less?

epoch1970
Posts: 6497
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Hostnames don't resolve until reboot

Mon May 10, 2021 8:51 am

generalveers wrote:
Mon May 10, 2021 1:40 am
Oh, wow, yeah -- when I try that, I get the proper hostname, but with a number appended. So, [hostname]-3.local, for example.
If a number is appended, it means that there is a duplicate of the host name already published. The name is taken, so the new host appends -1, the next -2 etc.
Reality looks to be a bit more fuzzy, I’ve seen “name-5” and “name-6” when 2 host names collide...

Perhaps try changing the hostname of the Pi (via raspi-config)?
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

generalveers
Posts: 43
Joined: Fri Aug 21, 2020 11:14 pm

Re: Hostnames don't resolve until reboot

Mon May 10, 2021 1:18 pm

MiscBits wrote:
Mon May 10, 2021 2:18 am
Are you running 2.4 and 5Ghz WiFi by any chance?

I've seen issues where some home routers 'forget' device names on the other network. BT have just been called out on this (see here) and I know tp-link have similar issues.

I'm pretty sure the older Airports (flat pizza-box style) APs from Apple have the same glitch but not 100% convinced I've tracked it down to the APs or an IGMP snooping issue.

It may be worth turning IGMP snooping off - sorted out a HP printer 'dropping off' the network here.
Thanks for the advice! I'm using an eero router, which I don't believe supports IGMP snooping, but I'll take a look!

generalveers
Posts: 43
Joined: Fri Aug 21, 2020 11:14 pm

Re: Hostnames don't resolve until reboot

Mon May 10, 2021 1:20 pm

epoch1970 wrote:
Mon May 10, 2021 8:51 am
generalveers wrote:
Mon May 10, 2021 1:40 am
Oh, wow, yeah -- when I try that, I get the proper hostname, but with a number appended. So, [hostname]-3.local, for example.
If a number is appended, it means that there is a duplicate of the host name already published. The name is taken, so the new host appends -1, the next -2 etc.
Reality looks to be a bit more fuzzy, I’ve seen “name-5” and “name-6” when 2 host names collide...

Perhaps try changing the hostname of the Pi (via raspi-config)?
Ah, yes, this makes perfect sense. (Well, except I'm not sure HOW or WHY this is happening, but I understand that it IS happening.)

To be clear: When I go into raspi-config, the hostname is still the original, with no number appended. So it's not a matter of changing it from, say, hostname-2 back to hostname, but more that I am changing it from hostname to newhostname, right?

epoch1970
Posts: 6497
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Hostnames don't resolve until reboot

Mon May 10, 2021 1:33 pm

Yes, try extremelyimprobable or something like that as a host name. Then reboot.

If it gets advertised as extremelyimprobable-1.local, then there is a networking problem, and for some reason the Pi hears its own publication and collides with itself...
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

generalveers
Posts: 43
Joined: Fri Aug 21, 2020 11:14 pm

Re: Hostnames don't resolve until reboot

Mon May 10, 2021 1:34 pm

epoch1970 wrote:
Mon May 10, 2021 1:33 pm
Yes, try extremelyimprobable or something like that as a host name. Then reboot.

If it gets advertised as extremelyimprobable-1.local, then there is a networking problem, and for some reason the Pi hears its own publication and collides with itself...
Will do. It sometimes takes several days for the problem to show up, so I may be radio silent for a little while. Thanks for your help!

generalveers
Posts: 43
Joined: Fri Aug 21, 2020 11:14 pm

Re: Hostnames don't resolve until reboot

Wed May 12, 2021 11:43 am

I'm back to announce that after responding to thisisanewname.local for a couple of days, it no longer responds.

When I run ps ax | grep avahi, I get thisisanewname-2.local.

So, yeah, something is causing a collision, but I have no idea what.

Return to “Troubleshooting”