How to Completely Disable the ‘Avahi’ Daemon (mDNS/Zeroconf) in Ubuntu Server

If you install Ubuntu Server, the operating system attempts to make network discovery as frictionless as possible by enabling the avahi-daemon by default. Avahi is an implementation of the mDNS (Multicast DNS) and DNS-SD (Service Discovery) protocols, often referred to as Zeroconf or Apple’s Bonjour. Its job is to constantly broadcast your server’s hostname and available services across the local subnet, allowing other machines to find your server simply by pinging hostname.local instead of memorizing its IP address.

While this is incredibly useful for home networks (finding a network printer or a media server), it is a massive security flaw for production servers in enterprise environments or cloud hosting. The Avahi daemon needlessly pollutes the local network with multicast traffic, consumes background memory, and actively advertises your server’s existence to every other machine on the VLAN. If you use static IP addresses or a proper internal DNS server (like bind9 or CoreDNS), you do not need mDNS. To properly harden your Ubuntu Server, you must completely disable the Avahi daemon.

Stopping and Disabling the Avahi Service via Systemctl

Because Avahi is managed by the systemd init system, you can immediately stop it from running and prevent it from launching at the next boot.

  1. Open a Terminal session (or connect to your server via SSH).
  2. First, stop both the main daemon and its associated socket from running:
    sudo systemctl stop avahi-daemon.service
    sudo systemctl stop avahi-daemon.socket
  3. Next, permanently disable the services so they do not automatically launch the next time you reboot the server:
    sudo systemctl disable avahi-daemon.service
    sudo systemctl disable avahi-daemon.socket

Uninstalling the Avahi Stack Entirely (Recommended)

Simply disabling the service leaves the binary files installed. If a future apt upgrade triggers a dependency check, the daemon might be silently re-enabled. The absolute safest way to harden your server’s networking stack is to purge the software completely.

  1. In the terminal, run the following command to completely uninstall the Avahi packages and delete their configuration files:
    sudo apt-get purge avahi-daemon avahi-utils
  2. Press Y when prompted to confirm the removal.
  3. Clean up any orphaned dependencies left behind (such as libnss-mdns):
    sudo apt-get autoremove

With Avahi completely eradicated from your system, your Ubuntu Server is now silent. It will no longer spam the local subnet with multicast packets broadcasting its hostname, significantly reducing its visibility to unauthorized network scanning while freeing up a small amount of system resources.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.