Often (maybe 80% of the time), when I reboot a machine running Avahi, it starts using machinename-2.local as it's hostname. All the machines on my network have unique hostnames, so there is no collision.

How do I prevent Avahi from appending -2 to hostnames?

(This turns out to be an incredibly difficult thing to Google for...)


This is also the case with OS X machines.

If the hostname is already in use on the network it bumps the counter to make the names unique again. I would suspect that the machine in question may have two netcards to the same network (cabled and wireless) or that you have a bonjour proxy running (which may be unknown to you) which helps sleeping machines by holding their hostname active. To be more certain you may want to describe your network better.

  • Sorry for the slow reply. I certainly don't have two network cards in either of the machines that do this. How would I determine if I have a bonjour proxy anywhere? – dty Jan 20 '15 at 14:40
  • Do you own any Apple devices? – Thorbjørn Ravn Andersen Jun 11 '16 at 7:56
  • Several network devices work as bonjour proxies which can result in the same behavior – Thorbjørn Ravn Andersen Jun 13 '16 at 6:45
  • Hmm. I've only got one device that should be acting as a Bonjour Proxy (I now understand the relevance of this more than I did a year ago!) I have an Apple TV, but no desktop Mac, AirPort or Time Capsule. I do have iPhone, iPad, MacBook and an Apple Watch, but I don't think any of those should act as a Bonjour Proxy. – dty Jun 14 '16 at 16:12
  • AppleTV does, if it is alone on the network. – Thorbjørn Ravn Andersen Jun 14 '16 at 22:56

In my case, this behavior is caused by a Plex Media Server inside a docker container which runs its own avahi-daemon. I'm using this docker image: https://hub.docker.com/r/linuxserver/plex/

The number was increased very often, without need to restart.

After stopping the docker container and a restart of avahi-daemon.service, the numbers disappeared.

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.