For some reason there is not a command that you could run to flush the local DNS cache on macOS. However there is a simple workaround to get clear the cache by killing the DNSresponder service πŸ™„ ….. but I always forget what the exact command is.

sudo killall -HUP mDNSResponder

What I did is created a little shell script named flushdns, make it executable and copied it over to /usr/local/bin (note: /bin is not user writable, trust me I have tried it πŸ˜‰ ).

If you are really lazy, you can copy the script over from GitHub, or just copy paste it from here.

#!/bin/sh
sudo killall -HUP mDNSResponder

Now open a terminal window and just run flushdns, it will ask for your password because of sudo and the dns cache will be flushed!

Hope this helps to reduce your frustration a bit πŸ˜€

Categories: macOS

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.