If your Mac is on a network where DNS changes are made frequently or occasionally, there might be a time where you’ll need to perform a DNS flush so that you can resolve a web address to the correct IP address. You might run into an issue where a computer on the network is setup with a dynamic IP address from a DHCP server and the IP address has changed since you last accessed it. In Windows, you would run the simple command of ipconfig /flushdns from a command line. In macOS, it depends on the version you’re running, and unfortunately, the command isn’t as easy to remember as it is in Windows.
How To Flush DNS Cache in MacOS
For each version below, you’ll need to be logged in with an Administrator account, and you’ll run the commands from Terminal.
macOS Sierra (10.12) and macOS High Sierra (10.13): This command will yield better results than the shorter command below. sudo killall -HUP mDNSResponder;sudo killall mDNSResponderHelper;sudo dscacheutil -flushcache
El Capitan Mac OS X (10.11) and macOS Sierra (10.12) and High Sierra (10.13): sudo killall -HUP mDNSResponder
Yosemite Mac OS X (10.10.4 and Higher): sudo dscacheutil -flushcache;sudo killall -HUP mDNSResponder
Yosemite Mac OS X (10.10 – 10.10.3): sudo discoveryutil mdnsflushcache
Lion Mac OS X (10.7), Mountain Lion Mac OS X (10.8) and Mavericks Mac OS X (10.9): sudo killall -HUP mDNSResponder
Leopard Mac OS X (10.5) and Snow Leopard Mac OS X (10.6): sudo dscacheutil -flushcache