2026年11月12日
2026年11月12日
How to Flush the DNS Cache on Linux, Windows, macOS and Chrome
This article is a localized edition of the Japanese original. Read the Japanese original
You clear (flush) the DNS cache when you have changed a DNS record but your computer or server still connects to the old IP address. A typical case is right after a server move, when you have pointed the domain's A record at the new server.
First, separate out the situations that clearing the DNS cache does not fix.
- You updated a post or the design in WordPress, but the page does not change: this is not DNS. It is a page cache (a caching plugin, the server's cache, a CDN) or the browser cache. Clearing the DNS cache will not change anything.
- Your own device sees the new server, but other people still see the old one: the cache of their ISP or public DNS resolver still holds the old record. You cannot clear it from your side; you wait for the record's TTL (the number of seconds it may be cached) to expire.
The commands in this article were checked against each OS's and program's official documentation as of November 2026.
First, check what DNS is actually returning
Before clearing any cache, check whether the authoritative DNS servers (the servers that hold the domain's records) return the new value. If they still return the old value, clearing caches will just bring the old value back.
# Find the domain's authoritative DNS servers
dig +short NS example.com
# Query an authoritative server directly (bypasses caches)
dig +short A example.com @ns1.example-dns.jp
# See the answer from the resolver you use now, with the remaining TTL (seconds)
dig example.com A +noall +answer
The second column of the last command's output is the remaining TTL. It goes down with each query, and when it reaches 0 the resolver asks the authoritative server again.
Linux: find out which cache is running
Which software caches DNS on Linux depends on the distribution and configuration. It is also common for no cache to be running at all (in that case there is nothing to clear on the OS side).
# Check where /etc/resolv.conf points
ls -l /etc/resolv.conf
grep nameserver /etc/resolv.conf
# Check whether the main caching services are running
systemctl is-active systemd-resolved nscd dnsmasq unbound named
If you see nameserver 127.0.0.53, systemd-resolved is in use (the default on Ubuntu). For each service reported as active, clear its cache as follows.
systemd-resolved
sudo resolvectl flush-caches
# Check the number of cache entries (Current Cache Size goes back to 0)
resolvectl statistics
systemd-resolve --flush-caches, found in older guides, is the old command name. Use resolvectl today.
nscd
nscd (Name Service Cache Daemon) caches host name lookups in a table called hosts.
sudo nscd -i hosts
-i invalidates the cache of the given table. Restarting the service has the same effect (sudo systemctl restart nscd).
dnsmasq
When dnsmasq receives SIGHUP, it clears its cache and rereads /etc/hosts.
sudo pkill -HUP dnsmasq
Some setups have NetworkManager start dnsmasq internally. The same command clears the cache in that case too.
Unbound
If you run Unbound as a caching server, use unbound-control (remote-control must be enabled).
# Remove A, AAAA and other records for one name
sudo unbound-control flush example.com
# Remove everything under the domain (including subdomains)
sudo unbound-control flush_zone example.com
BIND (named)
# Clear the whole cache
sudo rndc flush
# Clear a single name
sudo rndc flushname example.com
Checking that the cache is cleared
dig and nslookup query the server in /etc/resolv.conf directly, so they do not go through the nscd cache. To see the result of name resolution through the same path applications use (NSS), use getent.
getent hosts example.com
# If you use systemd-resolved
resolvectl query example.com
Also note that if /etc/hosts still contains the old IP address, it takes precedence even after you clear the cache. Make sure no line you added temporarily during a server move is left behind.
Windows
Run this in Command Prompt or PowerShell.
ipconfig /flushdns
You can view the cache contents with ipconfig /displaydns.
macOS
Run this in Terminal. You will be asked for an administrator password.
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
Browser (Chrome)
Chrome keeps name resolution results for a short time, separately from the OS. Enter chrome://net-internals/#dns in the address bar and click "Clear host cache." If connections that are still open point to the old server, also click "Flush socket pools" under "Sockets" on the left side of the same page.
If you still reach the old IP address after clearing caches
- If your home or office router caches DNS, restart the router or wait for the TTL to expire.
- The caches of ISPs and public DNS resolvers (8.8.8.8, 1.1.1.1 and so on) cannot be cleared from your machine. Google Public DNS and Cloudflare's 1.1.1.1 have pages where you can request that the cache for a specific name be purged.
- When the switchover date is fixed, as with a server move, lowering the record's TTL a few days in advance shortens the time old values linger after the switch.
Related procedures are covered in the following articles.
- DNS TTL settings and how to choose them
- What to check when a DNS change is not taking effect
- Configuring /etc/resolv.conf
Questions about WordPress? The publisher of this site is based in Japan and replies in Japanese. Contact (Japanese)