This post explains how to view/flush DNS cache from command prompt. The DNS resolver cache stores the IP addresses for the websites recently visited from this computer. If there’s a change made on DNS servers, you may want to flush the local cache so that it can fetch address again from DNS servers.
Flush DNS cache
Now let’s see how can we flush the contents of DNS cache using the windows command ipconfig.
Run the below command to flush dns cache
C:\>ipconfig /flushdns Windows IP Configuration Successfully flushed the DNS Resolver Cache.
Now if you print dns cache records, you may see it empty.
C:\>ipconfig /displaydns Windows IP Configuration Could not display the DNS Resolver Cache.
Note that it’s not guaranteed to see empty output with
/displaydns command, as there could be some application contacting some website in the background and the DNS cache is filled with new records immediately. But you can rest assured that all the previously cached records were deleted.
DNS flush is frequently used by domain admins when they update the hosting server address in their domain settings. Flushing removes the record stored on the local host and so triggers contacting the domain name servers(DNS servers) on the internet, which would fetch the latest updated IP address.
View DNS cache records
DNS cache entries can be retrieved using the below command.
C:\>ipconfig /displaydns Windows IP Configuration www.windows-commandline.com ---------------------------------------- Record Name . . . . . : www.windows-commandline.com Record Type . . . . . : 5 Time To Live . . . . : 272 Data Length . . . . . : 8 Section . . . . . . . : Answer CNAME Record . . . . : windows-commandline.com www-google-analytics.l.google.com ---------------------------------------- Record Name . . . . . : www-google-analytics.l.google.com Record Type . . . . . : 1 Time To Live . . . . : 58 Data Length . . . . . : 4 Section . . . . . . . : Answer A (Host) Record . . . : 22.214.171.124
There are more DNS records printed for the above example, showing only couple of records here.
- Q: DNS still points to the old IP even after flushing the cache and updating IP on domain name server(DNS server).
A: This would be because the update you made on your hosting DNS server would take some time to propagate to all other DNS servers over the internet. The DNS server your computer is looking up might not have received the update yet. The latency could vary from few seconds to few hours.