This guide will explain how to clear the DNS Cache on your Mac no matter which version of OS X or macOS you’re using.
This is a little bit silly but the command is different depending on the exact version of OS X or macOS you’re using. As an aside, it’s not going to hurt your Mac if you run the wrong command for the wrong version – it just won’t work.
If you’re using: Yosemite (10.10.4 and later), El Capitan (10.11), Sierra (10.12), High Sierra (10.13), Mojave (10.14), Catalina (10.15) and Big Sur (11).
Enter following Terminal command (and then your password when prompted) to clear the DNS cache:
sudo killall -HUP mDNSResponder
If you’re using: Yosemite (10.10 – 10.10.3)
Enter the following Terminal command (and then your password when prompted) to clear the DNS cache:
sudo discoveryutil mdnsflushcache
If you’re using: Mavericks (10.9), Mountain Lion (10.8), or Lion (10.7)
Enter the following Terminal command (and then your password when prompted) to clear the DNS cache:
sudo killall -HUP mDNSResponder
If you’re using: Snow Leopard (10.6)
Enter the following Terminal command (and then your password when prompted) to clear the DNS cache:
sudo dscacheutil -flushcache
If you’d like the background on any of these commands, see these pages: mDNSResponder, discoveryutil and dscacheutil