Flushing DNS cache on macOS

A drawing of a cartoon man pointing upwards

Heads up! This post was written in 2016, so it may contain information that is no longer accurate. I keep posts like this around for historical purposes and to prevent link rot, so please keep this in mind as you're reading.

— Cory

Here's the best way to flush DNS cache on macOS:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder; say cache flushed

Notice that last part — that's why this is the best method. You get an audible "cache flushed" almost instantaneously, and the whole process becomes that much more satisfying.

Another fun variation:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder; say booyah!

Have at it. It may be silly, but it's the little things in life. Now, go flush that DNS!