Flush the DNS Cache on Windows/Mac/Linux

If you work with websites or servers, someone has surely told you at some point that you have to clear or flush the DNS. This is because the operating system keeps a cache where it stores which IP each domain points to (browsers also have their own cache).

Clearing the Cache the Quick and Easy Way

A trick that has let us help people with less technical knowledge is to restart. If you restart the computer, this cache is emptied and the problem is gone: an easy and quick solution, but not so convenient.

It’s true that we can’t always afford the luxury of restarting, so now I’ll explain how to do it without having to restart.

Flushing the Cache on Windows

Flushing the cache on Windows isn’t complicated at all; we just need to follow these steps:

  • Go to the Start button
  • Search for Command Prompt
  • Type: ipconfig /flushdns
  • Press Enter

Flushing the Cache on Linux

Flushing the cache on Linux is simple, but how you do it depends on the distribution and tools you use. Depending on your system, you need to run a different command, but they are all run in the terminal.

Ubuntu / Debian / Arch Linux / Manjaro (if you use systemd)

sudo systemd-resolve --flush-caches

Centos/Almalinux/RHEL/OpenSUSE

If you are using nscd – Name Service Cache Daemon

sudo systemctl restart nscd

If you are using dnsmasq

sudo systemctl restart dnsmasq

Flushing the Cache on Mac

Flushing the DNS cache on a Mac depends on the operating system version you have. Here are the available options.


For:

  • macOS Big Sur (11)
  • macOS Catalina (10.15)
  • macOS Mojave (10.14)
  • macOS High Sierra (10.13)
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
  • macOS Sierra (10.12)
sudo killall -HUP mDNSResponder
  • macOS El Capitan (10.11)
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
  • macOS Yosemite (10.10)
sudo discoveryutil mdnsflushcache; sudo discoveryutil udnsflushcaches
  • macOS Mavericks (10.9)
  • Mountain Lion (10.8)
  • Lion (10.7)
sudo killall -HUP mDNSResponder
  • macOS Snow Leopard (10.6)
sudo dscacheutil -flushcache