How to flush the DNS cache on Windows, macOS and Linux
The exact command to clear the DNS cache on Windows, macOS and Linux, when it helps, and why a site can still load the old address afterwards.
Your computer remembers the address a website name points to. After a site moves, or after you edit the hosts file, the old answer can stay in that cache. Flushing it makes the computer ask again. It changes nothing else on your computer.
What to do, step by step
- Open a terminal: Command Prompt or PowerShell on Windows, Terminal on macOS or Linux.
- Run the command for your system from the list below.
- Close and reopen your browser, because browsers keep their own DNS cache too.
- Try the site again. If it still shows the old address, the answer is probably cached further away (see the table below).
Commands you can copy
ipconfig /flushdnsipconfig /displaydnssudo dscacheutil -flushcache; sudo killall -HUP mDNSResponderresolvectl flush-cachesresolvectl statisticsNotes for each system
- Windows
- ipconfig /flushdns flushes and resets the DNS client resolver cache. Microsoft says it also discards negative cache entries (failed lookups) and anything added dynamically. ipconfig /displaydns shows what is cached, including entries from the hosts file.
- macOS
- Run both commands together: sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder. Apple does not document this cleanly and the cache has moved between macOS versions, so running both covers you whichever version you have. You are asked for your password and there is no output when it works.
- Linux
- resolvectl flush-caches clears the resolver caches kept by the systemd-resolved service. It needs that service, and it was added in systemd version 239. If your system does not use systemd-resolved, there may be no system-wide cache to flush; check what DNS service you run.
- The site still shows the old address
- Other places also cache: your browser, your router, and your internet provider’s DNS server. You cannot flush the last two from your computer. Wait for the record’s TTL to pass, or try a different DNS server.
- You edited the hosts file and nothing changed
- Flush the cache after saving the file, then restart the browser. See the hosts file guide.
- Not a router problem
- Flushing DNS does not fix a router that will not open. If 192.168.1.1 will not load, use the router IP finder.
Questions about Flush DNS
- Is it safe to flush the DNS cache?
- Yes. It only throws away saved lookups, and your computer fetches fresh ones the next time you open a site. The first page you load afterwards may be a little slower.
- Does flushing DNS clear my browser history?
- No. DNS records and browsing history are separate. Browsers also keep their own DNS cache, which a restart clears.
- What is the difference between ipconfig /release and /flushdns?
- /flushdns clears the DNS cache. /release gives up your DHCP address and, per Microsoft, disables TCP/IP for adapters set to get an address automatically, so you lose your connection until you run ipconfig /renew.
- Do I need administrator rights?
- On macOS the commands use sudo. For Windows, Microsoft’s page does not say; if you get an access error, open the terminal as administrator.
Config generators for this
- Apache virtual hostHost a website from a folder with Apache, with or without .htaccess.