← All posts

systemd-resolved was disabled, and still took port 53 after the Ubuntu 26.04 upgrade

After a release upgrade a DNS container could not bind :53 because systemd-resolved was listening there, although it had been disabled for years. On 26.04 resolved also wakes up through its own sockets, and only mask stops that.

In my home lab one VM runs the authoritative DNS server for my internal zone as a container bound to :53. I release-upgraded it from Ubuntu 24.04 to 26.04.1, rebooted it, and the container did not come back:

failed to bind ... :53: address already in use

For about ten minutes the zone was not served. That much I expected to be routine. What surprised me was who held the port.

The service that was supposed to be off

ss -lntup 'sport = :53'
# udp UNCONN 127.0.0.53%lo:53  users:(("systemd-resolve",...))

systemd-resolved with its stub listener on 127.0.0.53:53. On this host it had been disabled since 24.04, for exactly this reason, and after the upgrade it was still disabled:

systemctl is-enabled systemd-resolved.service
# disabled
systemctl status systemd-resolved.service --no-pager
# Active: active (running)

Disabled and running at the same time. Something started it without asking the service’s own enablement.

Root cause: socket activation

systemctl list-sockets --all | grep resolved
# systemd-resolved-varlink.socket   systemd-resolved.service
# systemd-resolved-monitor.socket   systemd-resolved.service

On 26.04, systemd ships two sockets for resolved: systemd-resolved-varlink.socket and systemd-resolved-monitor.socket. The package enables them. Early in boot something makes a varlink call to resolved, the socket activates the service, and the service binds its stub listener on :53 like it always does.

disable only removes the service’s own WantedBy links. It says nothing about other units that can start it: sockets, dependencies, D-Bus activation. The only state that means “never start this, whoever asks” is mask, which links the unit to /dev/null.

The fix

Mask the service and both sockets, then recreate the container:

sudo systemctl mask --now systemd-resolved.service \
  systemd-resolved-varlink.socket systemd-resolved-monitor.socket
sudo docker compose up -d --force-recreate
ss -lntup 'sport = :53'
dig +short @<host> <zone> SOA

docker start is not enough here. A container whose network setup failed keeps that broken state, so it has to be recreated.

The rollback is unmask and start for the same three units. It takes :53 back, so stop the DNS container first.

One trap before masking: check /etc/resolv.conf. If it is a symlink to /run/systemd/resolve/stub-resolv.conf, the host loses its own name resolution the moment resolved is masked. Point it at a static file first.

A second surprise from the same upgrade

The upgrader also renamed third-party apt sources to *.list.disabled and added comment lines around the original entry. When re-enabling them, take only the # deb … line and change the release codename to the new one. Uncommenting the whole file breaks apt.

Takeaways

  • disabled means “not started by its own install links”. It does not mean “never started”. If a unit must never run, mask it.
  • After a release upgrade, check what got new socket or path units: systemctl list-sockets --all, not only list-units.
  • The same trap applies to any host with its own listener on :53: dnsmasq, Pi-hole, AdGuard, CoreDNS on the host network.
  • Add it to the pre-upgrade checklist: systemctl is-enabled systemd-resolved must say masked, not disabled.