Contents
10 sections · 5 min read
Linux terminal showing systemd-resolve flush-caches command
Domain Management

How to Flush DNS Cache on Linux (Ubuntu, Debian, CentOS, Arch)

A
Domain 360 Team
·July 14, 2026·5 min read

Linux DNS flushing depends on which DNS caching service is running — and this varies by distribution and configuration. Unlike Windows (always ipconfig /flushdns) or Mac (two fixed commands), Linux has several possible services.

Quick answer: Linux DNS flushing depends on which DNS service is running — systemd-resolved, nscd, or dnsmasq. Here is the right command for each common Linux distribution.

Step 1: Identify Your DNS Service

systemctl status systemd-resolved systemctl status nscd systemctl status dnsmasq

The one showing "active (running)" is your DNS caching service.

ubuntu flush dns — systemd-resolved (Default on Ubuntu 16.04+)

Ubuntu 18.04, 20.04, 22.04, 24.04, and Fedora all use systemd-resolved by default.

Flush command: sudo systemd-resolve --flush-caches

Verify: sudo systemd-resolve --statistics — look for "Current Cache Size: 0"

ubuntu flush dns cache — nscd (Older Systems)

If systemctl status nscd shows active:

sudo service nscd restart

nscd does not have a flush command — restarting the service clears its cache.

linux flush dns cache — dnsmasq

sudo killall -HUP dnsmasq

Or: sudo systemctl restart dnsmasq

linux clear dns cache — NetworkManager with dnsmasq

Ubuntu desktop may use dnsmasq embedded inside NetworkManager:

sudo systemctl restart NetworkManager

Note: briefly drops and reconnects network connections.

linux refresh dns — All Ubuntu Versions

Ubuntu 24.04: sudo systemd-resolve --flush-caches Ubuntu 22.04: sudo systemd-resolve --flush-caches Ubuntu 20.04: sudo systemd-resolve --flush-caches Ubuntu 18.04: sudo systemd-resolve --flush-caches Ubuntu 16.04: sudo systemd-resolve --flush-caches Ubuntu 14.04: sudo service dns-clean restart (if installed)

Verifying No Cache Exists

Many minimal Linux server installations have no local DNS cache. Every DNS query goes directly to the configured resolver without caching.

Check: systemctl list-units --type=service | grep -E "dns|nscd|resolved"

If nothing relevant appears as active, there is no local cache to flush. DNS changes take effect on the next query automatically.

When Flushing Does Not Resolve the Issue

If DNS flush does not fix the problem, test with public resolvers:

dig @1.1.1.1 yourdomain.com dig @8.8.8.8 yourdomain.com

If these return different results from your local query, your configured resolver is the issue. If they all return the same (wrong) result, it is propagation — the change has not reached these servers yet.

A domain returning NXDOMAIN everywhere may have expired — WHOIS lookup on the domain shows expiry status immediately.

Flushing DNS Inside WSL (Windows Subsystem for Linux)

WSL is a special case worth calling out separately, since it behaves differently from both native Linux and native Windows. WSL2 runs its own lightweight virtualized network stack, so flushing DNS on the Windows host (ipconfig /flushdns) does not touch the cache inside the WSL distribution, and vice versa. Inside the WSL shell, use whichever command matches the distribution you installed — Ubuntu on WSL uses the same systemd-resolve --flush-caches command as native Ubuntu in recent WSL2 versions with systemd support enabled, or a full WSL restart (wsl --shutdown from PowerShell, then reopening the terminal) if systemd is not enabled, which resets the entire network stack including any cached DNS state.

A Quick Reference Table

For fast lookup: Ubuntu 18.04+/Fedora/most modern distros use sudo systemd-resolve --flush-caches. Older distros or minimal installs using nscd use sudo service nscd restart. Systems running dnsmasq directly use sudo systemctl restart dnsmasq. Desktop systems where NetworkManager manages DNS use sudo systemctl restart NetworkManager. When genuinely unsure which applies, running the identification commands from Step 1 above takes ten seconds and removes the guesswork entirely.

Frequently Asked Questions

Never lose a domain again

Track every domain you own in one dashboard. Free for up to 15 domains.