How to Flush DNS Cache on Linux (Ubuntu, Debian, CentOS, Arch)
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.
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.
Never lose a domain again
Track every domain you own in one dashboard. Free for up to 15 domains.
