Applies to: Linux servers and desktops (systemd-resolved, nscd, dnsmasq), Windows 10 and 11, macOS, and web browsers
Your computer remembers DNS answers for a while, so after you change a domain’s DNS records or move a website to a new server, it may keep using the old IP address. Flushing the DNS cache makes it ask again. It only clears the cache on the device where you run it: other people’s computers and their internet providers keep their own copies until the record’s TTL runs out.
Windows
Open Command Prompt or PowerShell and run:
ipconfig /flushdns
You should see “Successfully flushed the DNS Resolver Cache.”
macOS
In Terminal (it asks for your Mac password):
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
Linux
First check whether the system has a DNS cache at all:
systemctl is-active systemd-resolved nscd dnsmasq
- systemd-resolved (the default on Ubuntu):
sudo resolvectl flush-caches resolvectl statistics | grep -i "cache size" # should now show 0
- nscd:
sudo nscd -i hosts - dnsmasq:
sudo systemctl restart dnsmasq
If none of them is active, there is nothing to flush. That is normal on AlmaLinux and Rocky Linux servers, where every lookup goes straight to the DNS servers in /etc/resolv.conf. We tested the systemd-resolved commands on a Ucartz VPS: the cache went from 2 entries to 0.
Web browsers
Browsers can keep their own copy. In Chrome or Edge, open chrome://net-internals/#dns (or edge://net-internals/#dns) and click Clear host cache. Closing and reopening the browser also works.
Check what the internet sees
dig +short example.com A @1.1.1.1 nslookup example.com 8.8.8.8
If a public DNS server already returns the new IP address but your computer doesn’t, flush your local cache. If the public servers still show the old address, the change hasn’t propagated yet, or the old record is still being served by your DNS provider. Your server’s own IP address: how to find your server IP address.
Ucartz services for this topic
- KVM VPS hosting: NVMe SSD and full root access, with Free Basic Managed Support.
- Unmanaged dedicated servers: full root access and free IPMI KVM, with Free Basic Managed Support.
- Linux server management: hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.
