On Windows, run ipconfig /flushdns; on macOS, run sudo killall -HUP mDNSResponder in Terminal; on Linux with systemd-resolved, run resolvectl flush-caches. Browsers keep their own cache too: in Chrome or Edge, open chrome://net-internals/#dns (or edge://net-internals/#dns) and click Clear host cache.
What the DNS cache is, and when flushing helps
When you visit a site, your computer asks a DNS server for the site's IP address and keeps the answer for as long as the record's time to live (TTL) allows. Later requests for the same name are answered from that cache without asking the server again.
Flushing helps when the cached answer is wrong or out of date:
- A site moved to a new server or hosting provider, and your computer still has the old address.
- You changed DNS records for your own domain and want to check the new ones without waiting for the TTL.
- A failed lookup was cached. If a name didn't resolve once (during an outage, or before a record existed), Windows can remember that failure. Microsoft's ipconfig reference says
/flushdnslets you "discard negative cache entries from the cache". - You changed DNS servers or connected to a VPN, and names that should now resolve differently still return the old answers.
It does not help when the problem is elsewhere: a site that is actually down, a router or ISP resolver that is itself caching the old record, a wrong entry in your hosts file, or general slowness.
How to flush DNS on Windows
Open Command Prompt or PowerShell and run the command below. It worked from a normal, non-administrator window on our Windows 11 test machine.
ipconfig /flushdns
Real output on Windows 11:
Windows IP Configuration
Successfully flushed the DNS Resolver Cache.
PowerShell has an equivalent cmdlet, Clear-DnsClientCache, which prints nothing on success.
See what is in the cache first
ipconfig /displaydns
Each entry shows the name, record type and remaining TTL in seconds. Example entry after visiting example.com:
example.com
----------------------------------------
Record Name . . . . . : example.com
Record Type . . . . . : 1
Time To Live . . . . : 182
Data Length . . . . . : 4
Section . . . . . . . : Answer
A (Host) Record . . . : 104.20.23.154
Record type 1 is an A record (IPv4 address); 28 is AAAA (IPv6). The list is long, so filter it. In PowerShell, Get-DnsClientCache -Entry example.com shows just one name, as objects.
Don't be surprised if the cache is not empty right after a flush. Microsoft's reference explains that the cache "includes both entries preloaded from the local Hosts file and any recently obtained resource records". On our test machine, which has a few dozen lines in its hosts file, Get-DnsClientCache still listed dozens of entries a moment after a successful flush. Nearly all of them were the hosts-file names and their matching reverse-lookup (in-addr.arpa) entries. Those are reloaded from the file, not from the network, so they are not stale.
How to flush DNS on macOS
Open Terminal and run:
sudo killall -HUP mDNSResponder
Type your Mac login password when asked (nothing appears as you type). The command prints nothing on success. It sends the hang-up signal to mDNSResponder, the macOS process that handles DNS lookups, which makes it drop its cache.
This is the command in Apple's support article for OS X Yosemite 10.10.4 and later. That article is archived and was last written for older releases; Apple has not published a newer one, and the article lists no different command for current versions. You will often see it combined with sudo dscacheutil -flushcache; Apple's article gives dscacheutil -flushcache only for Mac OS X 10.6 Snow Leopard.
How to flush DNS on Linux
Most current desktop distributions, including Ubuntu and Fedora, cache DNS in systemd-resolved. Flush it with:
resolvectl flush-caches
Add sudo if you get an authorization error. The man page describes it as flushing "all DNS resource record caches the service maintains locally". To check the cache before and after:
resolvectl statistics
Example output section (Ubuntu 22.04, systemd 249):
Cache
Current Cache Size: 0
Cache Hits: 0
Cache Misses: 6
After a flush, Current Cache Size is 0. Newer systemd releases also have resolvectl show-cache, which lists the cached records themselves; systemd 249 (Ubuntu 22.04) answers Unknown command verb show-cache.
Not every Linux system uses systemd-resolved. Check with resolvectl status: if it says the service isn't running, your system may not cache DNS locally at all (each lookup goes straight to the server in /etc/resolv.conf), or it may use another cache such as dnsmasq or nscd, which you restart through its service instead. WSL is a common example: in our Ubuntu 22.04 WSL install, /etc/resolv.conf pointed at the Windows host's virtual network address (nameserver 172.18.32.1) rather than at systemd-resolved, so resolvectl flush-caches inside WSL has nothing relevant to clear. Flush the Windows cache instead.
How to clear the browser's DNS cache
Chrome, Edge and other Chromium-based browsers keep their own host cache, separate from the operating system's:
- Open
chrome://net-internals/#dns(in Edge,edge://net-internals/#dns). - Click Clear host cache.
- Open
chrome://net-internals/#socketsand click Flush socket pools, so open connections to the old address are closed too.
In Firefox, open about:networking#dns and click Clear DNS Cache. Restarting the browser clears these caches as well.
If the old address still shows up
- Check what your computer is getting. Run
nslookup example.com(all systems) orResolve-DnsName example.com(PowerShell). If the answer is still the old IP right after a flush, the stale record is upstream, not on your machine. - Ask a different DNS server directly, for example
nslookup example.com 1.1.1.1. If that returns the new address and your default server doesn't, your router or ISP resolver is caching the old record until its TTL expires. Restarting the router clears its cache. - Check the hosts file. An entry in
C:\Windows\System32\drivers\etc\hostsor/etc/hostsoverrides DNS entirely. - Check for a VPN or secure DNS setting. A VPN, or the browser's "Use secure DNS" option, sends lookups to a different server than the one your system uses.
Frequently asked questions
- Is it safe to flush the DNS cache?
- Yes. The cache only holds copies of recent lookups. Flushing it deletes those copies, and the next request for each name goes to your DNS server again. The only cost is that the first visit to each site afterwards takes a few milliseconds longer while the name is looked up again.
- How long do DNS entries stay cached if I don't flush?
- Each record carries a time to live (TTL) set by the domain's owner, in seconds. Your computer keeps the record until the TTL runs out. On Windows, ipconfig /displaydns shows the remaining Time To Live for each cached entry, so you can see exactly when it will expire on its own.
- Does flushing DNS make my internet faster?
- No. The cache exists to make lookups faster, so emptying it makes the next lookup of each name slightly slower, not faster. Flushing only helps when the cache holds a wrong or outdated answer.
- Do I need to restart my computer after flushing DNS?
- No. The flush takes effect immediately. You may need to close and reopen the browser, or clear its own DNS cache, because browsers and some apps keep a separate cache and keep connections open to the old address.