You fixed the DNS record, and your Linux box keeps serving the old IP anyway. On modern Ubuntu, Debian and Fedora the fix is sudo resolvectl flush-caches, because systemd-resolved is what's caching. Unlike Windows there's no single universal command, though. Older or lighter systems run nscd or dnsmasq, each cleared its own way, and plenty of Linux machines run no local cache at all, so there's genuinely nothing to flush. We'll show you how to tell which resolver you've actually got, the exact command for each one, how to confirm the cache emptied, and where the stale record hides when it lives outside your machine.
The short answer
Find out what actually caches DNS on your box first. On modern distros it’s systemd-resolved: sudo resolvectl flush-caches. On others it’s nscd or dnsmasq, each restarted its own way. And plenty of Linux machines cache nothing locally, so there’s nothing to flush.
Find which resolver you run, then flush it
resolvectl status
A Global block listing DNS servers means you’re on systemd-resolved, so jump to Step 2. If resolvectl comes back command not found, you’re on nscd or dnsmasq (Step 3), or nothing local caches DNS and you’re already done.
sudo resolvectl flush-caches
Done. It clears instantly, and no output means success. On older systemd releases the same command is sudo systemd-resolve --flush-caches.
Running a separate caching daemon? Restart it. For nscd:
sudo systemctl restart nscd
For dnsmasq (common on routers and on setups using NetworkManager’s resolver):
sudo systemctl restart dnsmasq
Confirm the cache is empty
Don’t just trust it. For systemd-resolved, the statistics show the live cache size:
resolvectl statistics | grep "Current Cache Size"
It reads 0 straight after a flush, then climbs as new lookups land. The full sequence:
When there’s nothing to flush
We see this a lot on minimal server installs: no local DNS cache at all. The stale answer you’re chasing sits at the router or the public resolver, held there until its TTL expires, and no command on your box will hurry it along. macOS is different again (honestly, I look that one up every time): there it’s sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder.
On Windows? One command for everyone: see how to flush the DNS cache on Windows.
Worth saying plainly: plenty of Linux desktops and most minimal servers have no DNS cache at all. If nothing is running systemd-resolved, dnsmasq or nscd, then every lookup already goes straight to your resolver and there’s nothing to flush. A stale answer in that case is coming from the upstream resolver or from the application, not from your machine.
One naming trap on systemd. The old systemd-resolve --flush-caches was renamed to resolvectl flush-caches in systemd 239, and the old name lingers in half the answers online. Both work on many distributions because the old binary is kept as a symlink, but on a recent Ubuntu the modern form is the one to use. Check the effect rather than trusting the exit code.
resolvectl statistics
Frequently asked questions
How do I know if I use systemd-resolved?
Run "resolvectl status". A Global section with DNS servers means systemd-resolved is active and caching. If the command doesn't exist, you're on nscd or dnsmasq, or you’ve no local cache at all.
What’s the command on older systemd versions?
Before resolvectl existed the same job was "sudo systemd-resolve --flush-caches". Many systems still keep it around as an alias, so it's worth a try when resolvectl is missing but systemd-resolved is clearly running.
My distro has no local resolver. Where is DNS cached then?
Then nothing on your machine caches it. The record sits with whatever resolver /etc/resolv.conf points to (your router, or a public resolver such as 1.1.1.1) and it stays put until its TTL expires. Our DNS TTL guide explains that wait.
Does flushing the cache need sudo?
Yes for the flush itself (resolvectl flush-caches, or restarting nscd or dnsmasq), since you're touching a system service. Reading the status and statistics works fine without it.





















