flush DNS Cache in Lion

If you need to flush the DNS cache in Mac OS X, be aware that the commands for this have changed through successive OSs, including Lion.

Flushing the cache is sometimes a good idea if you are unable to reach a site that you know is live but keeps returning an error (you can check whether a site is live for others by typing its address here: Down for everyone or just me?).

You can download my free app FastTasks that will do this (and a whole lot more! 🙂 ) for you without you needing to mess around on the command line. However, if you want to do it manually, then open Terminal (Applications > Utilities > Terminal.app) and use the appropriate command for your operating system:

In Tiger
lookupd -flushcache

In Leopard / Snow Leopard
dscacheutil -flushcache

In Lion and Mountain Lion
sudo killall -HUP mDNSResponder

With Lion, you’ll have to follow the command with your Admin password, which will be invisible when you type it.

Related Posts
FastTasks – a utility for common terminal tasks


About philastokes

Independent Software Developer, Technical Writer and Researcher at SentinelOne. Explaining the unexplainable with images, video and text. Scripting anything imaginable in AppleScript, Bash, Python and Swift.

Posted on April 16, 2012, in Mountain Lion, OS X Lion, Snow Leopard and tagged , , , , , , , , , , , , , . Bookmark the permalink. 4 Comments.

  1. I found your post via a Google search after becoming unable too get to a live site from my computer.

    I had used MAMP Pro for local development of a site and somehow I became unable to resolve to the live site. I tried everything I could think of including reseting MAMP to its default setting, uninstalling it completely, and finally using the flush DNS command.

    I had never heard of the “Down for everyone or just me?” site you link to and when I tried that it indicated that it was just me (I knew it would since my desktop was the only computer that wouldn’t resolve to the live site) and hoped it would give me more information.

    Have you got any idea what the problem could be and how to fix it?

    Your post is four months old so I hope you see this.

    • Does another computer (or smartphone) using the same router as the one in your house have the same problem? If you can connect to the site through that router on a different machine, I’d suggest looking at the etc/hosts file on your desktop and see if the affected site’s domain name has somehow got included in there. To do that, open Terminal, and type

      sudo emacs /etc/hosts

      press ‘return’ and enter your password (typing will not be echoed to the screen so type carefully). Press ‘return’ again.

      Is the domain name of the affected site listed there? If it is, type a # before it on the same line, then save the file by pressing ‘control-X’ and then ‘control-S’ immediately afterwards. You can then press ‘control-C’ to close emacs.

      If other machines can’t access the site on the router, then the problem is most likely a router somewhere down the line that is dropping the connection, or your ISP is blocking that domain name for some reason. You could try changing your DNS settings to OpenDNS or Google. There’s a good tutorial on how to do that here:


      Hope this helps.


      • I was able to access the site on other computers through my router so I knew that wasn’t it.

        Your instructions for the etc/host file did the trick though, thanks.

        Also your site was the only one I came across that had the flush DNS instruction specific to Mountain Lion.

        Thank for the help


      • Thanks so much. I ran a local server for wordpress theme and plugin development and ran into the same problem. I spent weeks trying to figure it out. This post and comment did the trick. I signed up just to say thanks for tips. Does the mamp local server always mess with host file?

%d bloggers like this: