Flush the DNS cache on Windows workstations
In one of my previous post (“Moving your website to another server? Tune your DNS for minimum downtime”) I have showed how we can tune DNS servers to minimize the downtime during a server migration. One additional concern that we might face on this issue is with client side DNS caching… Some operating system (MS Windows for example) will not follow DNS standards and will just cache the DNS records and will not query for them even if we have setup everything properly on the server side. This will happen even if the resolver for the Win workstation is a Linux server (or something else) that will correctly see the change.
This is my first (and hopefully the last) post that contains information about ms windows, but you might find it useful if you are doing a migration for someone else that uses windows on his workstation or even if you are working yourself from a windows system. There is a high chance that this will happen if you will check the site prior to making the DNS change and then it will be cached by windows. Since I have heard peoples recommending restarting the computer to clean up the local DNS cache, I have decided to write this little post…
Windows workstations
As I explained previously windows will cache the DNS hostnames and if you don’t want to reboot the workstation you will have to clear its internal cache so it will query again the DNS resolver that will hopefully follow the standards and get the correct IP. In order to do this open a command prompt (Start/Run then type cmd) and type:
ipconfig /flushdns
The output of this command will look like:
C:\\Documents and Settings\\user>ipconfig /flushdns
Windows IP Configuration
Successfully flushed the DNS Resolver Cache.
Just as a note this will obviously clear the entire local dns cache.
Linux workstations
Normally this will not happen on Linux workstations as the linux resolver will follow the standards and query for the new IP once the TTL will expire. Anyway if you want to clear the DNS cache even in this case (maybe for a case where the TTL was not expired yet for ex.) you have to restart the DNS service. If you are using bind you only have to run:
/etc/init.d/bind9 restart
on Debian based systems, or:
/etc/init.d/named restart
on RedHat based systems.
I guess that this was just a silly reason to insert some Linux related information in this post as probably everyone knows how to do that… :-)…
>







9th August 2006, 13:21
Marius, you are so right about…
(MS Windows for example) will not follow DNS standards and will just cache the DNS records and will not query for them even if we have setup everything properly on the server side. This will happen even if the resolver for the Win workstation is a Linux server (or something else) that will correctly see the change.
I think it has something to do with TTL(Time To Live), or NOT ?
9th August 2006, 13:41
Yep… Unfortunately, regardless on the TTL value, Windows will cache the value infinitely from what I know (until reboot or manual flush).
14th August 2006, 10:18
I have the similar problem in my LAN environment as well - I have internal DNS serve some internal hostname but Windows client always give me error. For a quick solution, just add into Windows host file.
7th September 2006, 07:56
For linux workstations its not needed to restart named/bind9 completely. You can flush the cache with the following command:
If you run a BIND 9.2.0 or newer name server, you can flush the cache with
# rndc flush
With older name servers, you still need to restart named to flush the cache.
26th January 2007, 01:46
Hi , Say I use the W2K Professional or XP as a user and the state of dns client is disabled and I try out ipconfig/flushdns , it gives an error …..Since I updated my hosts file to block off unnecessary sites as a security measure . Then what is the alternative ?
26th January 2007, 08:08
Usha,
No idea… Maybe you are seeing application level caching and this can be solved by restarting the application. hth.
2nd May 2007, 22:23
i get an error saying could not flush the dns resolver cache: function failed during execution. any help would be much appreciated, i think it is slowing down my internet speeds…
15th May 2007, 08:58
I have the same problem as you brad. My internet connection has become 50 times slower over the last week and i cannot delete the DNS cache.
I have fixed it before but i cant remember how as it was more than a year ago.
Anyone know how to fix this please?
19th May 2007, 12:21
..Same problem as Brad
I was trying to repair my wireless connection but windows could not finish the operation because it could not clear the DNS cashe?
I tried to do this using ipconfig/flushdns but this failed also?
1st September 2007, 07:31
There are 2 problems that interact with each other to make a very big problem: the caching in Windows (DNS Resolver Cache), and the “added extra” caching in Internet Explorer. In the Bad Old Days IE would cache for 24hrs. On current MS software you should get away with a few minutes of caching for A records and 30 min of caching for aliases (CNAME records). There is a good article on the site above with info on registry hacks and links to tools. Obviously if you play with your registry, it’s your funeral.
If you can’t be bothered with any of this, close all IE windows, and/or just reboot.
PS. The people reporting problems with running ipconfig /flushdns, there are some known bugs, check support.microsoft.com
1st September 2007, 07:36
… and as for how to refresh your DNS server data on Linux, can’t you just send SIGHUP to the ‘named’ or BIND process? That works on other flavours of unix.
3rd September 2007, 11:12
Spike: thank you for your pertinent addition.
25th May 2008, 10:09
yes in some cases a reboot will be needed. ipconfig /flushdns is not working and I’m using firefox so it is not an IE issue I will need to reboot tred and tried no go