Clear DNS cache on your Mac in Terminal

I know this is posted all over the Internet, but I keep forgetting it and someone may find it useful if they can’t find it anywhere else. It basically flushes your dns cache so your computer is forced to request the name server information afresh the next time you make a request to any URL.

This is especially helpful if you are a web developer and you’re mucking around with name server configurations and you can’t quite figure out why things aren’t updating.

I also use it when I’m playing around in /etc/hosts and for one reason or another it doesn’t update right away.

For Tiger

Type this into the Terminal

lookupd -flushcache

and …

for Mac OS X 10.5 (Leopard)

we use this:

dscacheutil -flushcache

Zippity-doo-da you’re done!

2 thoughts on “Clear DNS cache on your Mac in Terminal

  1. Thanks for the info. Is there a way to look at the DNS Cache and see the entries in OSX Tiger?

  2. it’ll be something like “lookup -d” then type in allHosts

    On Leopard it should be “dscacheutil -cachedump -entries” but that gives me an error on lookup. So you might have to hit the man pages.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong> <pre lang="" line="" escaped="" highlight="">