Saturday, August 22, 2009

Easy Ways to Flush DNS Cache in Mac, Windows and Linux

Each web server has a unique IP address, and whenever you open a website in your browser, all communication between your computer and web server takes place on the basis of IP address.

When you type www.google.com in your browser’s address bar and press enter, the browser must first know the IP address of the web server that hosts www.google.com, so that it can request it for the web page. This process to translate a domain name into Ip address is called DNS Resolution.

The Process of DNS Resolution (Simplified)

  1. When you type www.google.com in the address bar of your browser, the name www.google.com is first checked in the local DNS cache. If the entry is found there, the request for the web page is sent to the respective IP address.
  2. If there is no entry in the local DNS cache, then the HOSTS file is checked. If the HOSTS file contains the entry, then the request is sent to that IP address.
  3. f both the local dns cache and Hosts file knows nothing about the domain name, then the name is resolved recursively with the help of DNS servers.

Why you need to flush your DNS Cache?

You must flush (clear) the DNS cache whenever you want to get a domain name to be resolved again.

DNS cache ensures that the domain name is resolved fast, so that you don’t have to wait for it. However, sometimes DNS cache may cause some problems like page not loading and 404 errors. This may happen because the web server that hosts a particular web page changed its IP address, but the DNS cache still tries to get the page from the older IP. Also if you register a new domain, you must flush DNS cache so that it is resolved properly on your computer.

How To Flush DNS Cache in Mac, Windows and Linux?

To Flush DNS cache in Microsoft Windows Vista, XP, 200 etc.
  • Open command prompt. Start->Run, type cmd and press enter.
  • Type the command ipconfig /flushdns and press enter.
  • Done!
To Flush DNS cache in Linux, you need to restart the nscd daemon(service)-
  • Open terminal, type /etc/rc.d/init.d/nscd restart and press enter.
  • This command will restart the daemon and your DNS cache will be flushed automatically.
To Flush DNS cache in Mac OS X Leopard-
  • Open terminal, type lookupd -flushcache.
  • This command will flush the DNS cache.
To flush the DNS cache in Mac OS X-
  • Open terminal, type dscacheutil -flushcache.
  • This command will flush the DNS cache.
Important Note - The process explained above is an oversimplified picture of DNS resolution. It is a bit more complex then this. If you are interested in mastering the technical details, then follow the links in the above articles or contact me using the comments.




5 comments:

  1. hey man, i did this a while ago so i could load content from a specific webpage. you have a pretty good blog. if you have the time, check mine out

    www.everybodylovesshiraz.blogspot.com

    ReplyDelete
  2. Thank you, I was trying to load Secondlife, and it was popping up a "unable to find simulator" bug.

    I was lead here, followed your instructions, and it worked wonders.

    Thank you again. :)

    ReplyDelete
  3. I tried the ipconfig/flushdns command and it told 'The requested operation requires elevation'
    Windows Vista 32

    ReplyDelete
  4. run the command line as administrator (right click to do that) and then once you are running as Administrator, then it will not say it requires elevation.

    ReplyDelete
  5. Login failed. DNS could not resolve the host name. Please verify that you can connect to www.secondlife.com web site. If you can, but continue to receive this eror, please go to the support section and report this problem.

    ReplyDelete