On current Ubuntu releases, systemd-resolved commonly provides the local DNS resolver. Flush it with resolvectl, but first confirm that this is the resolver your environment actually uses.

Identify the active resolver

resolvectl status
systemctl is-active systemd-resolved
readlink -f /etc/resolv.conf

A container, customized server or VPN client may use another resolver. The target of /etc/resolv.conf and the active services are more useful than assuming every Ubuntu machine is identical.

Flush systemd-resolved

sudo resolvectl flush-caches

This asks the resolver service to clear its cache. It does not change configured DNS servers, repair a disconnected network or clear caches in browsers and remote DNS servers.

Verify the result

resolvectl statistics
resolvectl query example.com
getent ahosts example.com

The statistics command can show cache counters when supported. Query the actual hostname that caused trouble after flushing. getent follows the system’s configured name-service path and may differ from a direct DNS lookup.

If another cache is running

systemctl is-active dnsmasq nscd unbound named

Restart only the caching service you confirmed is responsible, using its documented procedure. Do not restart the entire network just to clear DNS: it can interrupt remote sessions without fixing the underlying server or routing problem.

If resolution still fails

Follow the Ubuntu name-resolution checklist to separate DNS failure from a general connectivity problem. If a renamed machine is resolving to an old address, review the hostname and DNS update steps.

Sources and verification

The cache-flush method was checked against the systemd resolve1 interface on September 11, 2026. Resolver topology varies with VPNs, containers and local caching software.