About the author

Steven HarmanSteven Harman is a passionate developer who believes that writing great software isn't just a job, its a craft.

ASP.NET MVP

For recent posts and more about me, scroll to the bottom.

Subscribe

  • Subscribe to my feed. via RSS
  • Subscribe via email via email

News

devLINK Technical Conference

Jobs

Badges

  • Subtext Project
  • Support Subtext
  • HiddenNetwork.com Banner

Quick Tip: Clear You DNS Cache

Admin Command PromptNeed to clear you machine’s DNS Cache? Running Microsoft Windows? It’s pretty simple and straight forward.

  1. Fire up a Command Prompt
  2. Run the following command

> ipconfig /flushdns

You can also take a look at what’s in your DNS resolver cache with the following command

> ipconfig /displaydns

Why would you clear your cache?

Most DNS clients will cache the results of name resolution request to speed up multiple lookups to the same URL. Just think about how many requests are made to the same domain when visiting a single web page. Every file, image, style sheet, etc... that is on that page and served from the same domain requires a DNS lookup.

So if you have an invalid DNS entry cached on your local client you’ll need to flush it out of the cache so your client can do a new lookup and get the correct information. Or your other option is to wait until that DNS entry expires and the cache flushes it automatically... which typically takes about 24 hours.

Other OSes?

Not to hate on fans of other OSes out there - especially since I totally dig both Ubuntu and Mac OSX - here is how you clear the DNS client cache for both Linux and OSX.

In Mac OSX:

From a command (or terminal window... depending on where you come from) run this command

$ lookupd -flushcache

In Linux:

Updated based on comments from nop. The DNS cache is actually managed by the nscd daemon for Linux boxen, so you just need to restart the daemon. You can do that using this command

sudo /etc/init.d/networking restart

= If you’re running Vista, you’ll need to run the Command Prompt with elevated privileges. You can do this either using the Run as administrator context menu item, or do what I do and use Start++ and the sudo startlet to launch the Command Prompt.

Technorati Tags: , , , , , , ,

What others are saying.

# re: Quick Tip: Clear You DNS Cache
Gravatar Damien Guard
Sep 25, 2007
Another option is to use the 'repair' option for a network connection. It does a bunch of other things that will involve connections being lost but may not need admin privileges on Vista?

[)amien
# re: Quick Tip: Clear You DNS Cache
Gravatar nop
Oct 17, 2007
Dude, fix the typos. Second, that ^^ crap doesn't work in Ubuntu.

later
# re: Quick Tip: Clear You DNS Cache
Gravatar Steven Harman
Oct 17, 2007
nop, rather that just being a fly-by critic, why not help me out an provide a working solution for Ubuntu.

Oh, and I think I fixed the typo you were referring to, but I can't be sure since you didn't actually point out the problem. So let me know.

Thanks.
# re: Quick Tip: Clear You DNS Cache
Gravatar nopsucks
Oct 23, 2007
re: ubuntu - http://ubuntuforums.org/showthread.php?t=156577
# re: Quick Tip: Clear You DNS Cache
Gravatar Steven Harman
Oct 23, 2007
@nop Thanks! I've updated the post accordingly.

I should also mention that anyone reading this and trying to flush the DNS cache for Ubuntu (or other Linux distros too) should really to read the thread that nop linked to above. It explains that Linux doesn't cache the DNS lookups, not by default anyhow...
# re: Quick Tip: Clear You DNS Cache
Gravatar George
Nov 15, 2007
trying to clear dns cache, have windows XP Pro, went to run, tried the posed ways, through config, but it didnt work, got any other ideas,?
# re: Quick Tip: Clear You DNS Cache
Gravatar Jon
Dec 19, 2007
George; If you're inside a Windows domain, check to see if your Active Directory / Domain Controller / DNS server is also refreshing and serving the right information. That one had me hacking the Windows equivalent of /etc/hosts for waaaay too long before I relaized the culprit. *foreheadsmack*
# re: Quick Tip: Clear You DNS Cache
Gravatar georgep
Jul 03, 2008
would this help solve this error I'm getting with certain domain on IE browser?

Bad Request
Your browser sent a request that this server could not understand.
Size of a request header field exceeds server limit.
et a 404 bad request error:
# re: Quick Tip: Clear You DNS Cache
Gravatar ahmed
Jul 11, 2008
i did exactly what u said but i get this message:
could not flush the DNS Resolver Cache: function failed during execution. any idea to solve this problem.

my operating sustem: xp sp2
Comments have been closed on this topic.