English
+370 5 205 5502 sales@monovm.com

How to Clear DNS Cache on Windows, Flush DNS

How to Clear DNS Cache on Windows, Flush DNS, In this tutorial, we will show you how to clear the DNS cache on Microsoft Windows OS.

20 Apr, 21 by Adrian A 12 min Read

List of content you will read in this article:

We all face internet problems now and then, and something that we all come across is websites not loading properly and visiting certain web pages becomes difficult. This usually happens when the websites change servers and are no longer associated with the cached address. Another factor that might be a factor is malware injection by cyber hackers who try to redirect you to fake websites containing malicious links. 

The only solution for removing all such problems is to clear your DNS cache. A Domain Name System (DNS) is like a phonebook or directory used for identifying web addresses from recent visits. The data collected from search activity is stored in a DNS cache and helps retrieve websites without using many resources. 

DNS caching is an excellent way to increase user web experience because it doesn't waste time in the server's lookup process. Users can directly go to their desired web page if their OS visited it before. With the help of DNS, the operating system also gets to experience less load in dealing with redundant searches. 

The latency goes down, and access speed goes up after using DNS cache to your advantage. However, there are some negative effects if the DNS cache is stored for too long, and if it impacts the web performance, one should consider clearing the local storage of the DNS server. This article will take a deep look at DNS caching's different aspects and learn how to clear DNS cache on different OS platforms. 

We all access websites by typing a domain name in the address bar of the web browser, but the domain name is directly not linked to the Internet, so we must need an intermediary to convert domain names to IP addresses. That is where DNS comes in and facilitates web browsers in using internet resources. The server does all the work in checking if the domain exists, and if it does, it converts into complex and unique IP addresses that can be loaded using the Internet. 

Loading web pages for users and giving them access is done by DNS, and it involves four main servers in the process. They are DNS precursor, nameserver, TLD nameserver, and Authoritative nameserver. Each of them fulfills a specific requirement in translating domain names to IP addresses, and loading user desired web pages. The information entered in the address bar is sent to the Internet Service Provider (ISP) in the DNS query. There will be multiple servers and databases storing DNS names and what their IP addresses represent at the end of the service provider. If there is a perfect match with any option present in the database, the user's computer gets an answer from the authoritative nameserver to connect to the respective website. 

If the service provider's directory has no match for the DNS query, the system proceeds to check the server cache. If the user's query is found in the cache, it is called a non-authoritative answer, and it is coming from a third=party, not your ISP. The last scenario you can is your DNS query is not present in an authoritative nameserver and system cache. In this situation, you have to the DNS precursor to control the information present in other servers in contact. This will narrow down the search and form a stable connection with the website. 

  • Press the Windows Key + R in order to open the run box.
  • Write CMD inside the box and press enter.

How to Clear DNS Cache on Windows, Flush DNS

  • Write the following command in the CMD and press enter.

  ipconfig /flushdns

  • You should receive the following message:

How to Clear DNS Cache on Windows, Flush DNS

 Successfully flushed the DNS Resolver Cache.

We now know that DNS helps users load websites, and it is responsible for the lookup process in its server. The websites that users visit are put inside local storage called DNS cache. This is used for faster retrieval and loading of sites that users previously visited. The one problem with DNS cache is that it doesn't update its storage data when the webserver changes the IP addresses, so users keep facing HTML 404 error code when trying to access the same domain name present in the DNS cache. If this repeats multiple times when browsing, it is a clear indication to remove the DNS cache from your system. When the DNS cache is cleared, the computer will use query nameservers to store new DNS information. 

Performance and website reliability will increase when DNS caching is implemented. The data requests sent by the user are instantly solved when the server stores previously visited domain names. Even the placement of storage matters to resolve DNS queries. The local storage is deployed closer to the requesting client, and in this way, they can avoid DNS lookup chains. The locations in which DNS data is stored also vary, and it is fixed for a set amount of time. Some of the main locations are as follows: 

Browser DNS caching 

Every modern web browser is designed so that the DNS caching is run on default for a fixed amount of time. The concept attached to browser DNS caching is simple- if DNS caching is done near the web browser, the steps required to fulfil data requests and find the right IP addresses will decrease. 

Operating System-Based DNS Caching 

If the data request makes its way to the operating system DNS resolver, it is the last stop to solve the query before leaving the machine. Stub Resolver handles this process. It is also called a DNS client, and the way it operates is that it first sends the data request to its cache and checks if there is a match or not. If there is no match for the IP address, the DNS query is combined with a recursive flag set and is sent out of the local network. The resolver continues to check with the Internet Service Provider to complete the request. 

Recursive Resolver DNS Caching

The recursive resolver is responsible for determining the presence of host-to-IP address translation inside the local layer. The functionality is also dependent on the type of records the resolver stores in its cache. If the resolver contains NS records, it will clear the DNS query by directly looking up the nameservers. Similarly, if the resolver does not come with NS records, the DNS query is sent to the TLD servers. If there is no match concerning TLD servers, the next step to fulfil the query will be root servers. 

If there is an entry made in the DNS cache, the information or units are called resource records (RR). These records are usually displayed using the ASCII code or in compressed format. The components included in the code are as follows:

  • Resource data provides resource Data- Description of a record. It can be the address or even the hostname. 
  • Record Type- The entries are also of different types: "A" is given an IPv4 address, whereas "AAAA" is given an IPv6 address. 
  • Record Name- While recording an entry, the name is optional for the object on which the access was created. 
  • Time to Live- Another optional component used to extend or limit a resource record's validity period. 
  • Class- This is a protocol group for DNS cache. 
  • Data length- The length represents the value assigned to resource data. 

It makes sense to clear the DNS cache every day, but it is impossible until TTL expires. However, it can be done when you set the register value to zero, and the validity period will not be prioritized anymore. Some benefits for clearing DNS cache regularly: 

No more Data Tracking

We know that the primary trackers of our data and user behaviour are cookies and JavaScript, but DNS cache can also behave in the same way and give data collectors a chance to exploit user web experience. By clearing your DNS cache regularly, you are not allowing the trackers to get hold of large sample sizes of cached addresses. If you do it periodically, like once in a month, you reveal yourself more to the Internet and the chance of being the next victim increases. 

Improves Security

One of the most important reasons you delete DNS cache regularly is to increase your computer security. Suppose. In that case, someone outside of your network accesses your local storage. They will be in a perfect position to hijack everything on your system, and manipulation becomes relatively easy. In technical terms, this is called DNS poisoning, and one of the examples in real-life is online banking. 

Eliminates Technical Issues

If the cache gets overloaded, it can create several technical problems for your server. Outdated entries are one common technical problem that almost every user faces while web browsing. The IP addresses change for the domain names, so if the cache does not have the updated version, then browsers will keep showing error messages. 

To check your local store for DNS cache, you must sequence steps, which again depends on the operating system you are working on every day. The process, however, remains the same across every mainstream developer. You would also need administrative access to have a look at the entries, and if you have access, you can follow the instructions below: 

For Windows

In this operating system, it is relatively easy to display the records, and all it takes is one step. Enter the command "ipconfig /displaydns" in the command prompt, and a window pops up displaying your entries in the DNS cache.

For MAC

In MAC OS, the user must first open the Terminal app and enter the command "sudo discoveryutil udnscachestats". After entering the command in the terminal app, you will have to input your password. The system immediately displays the records present in the Unicast DNS cache. If you want to know Multicast DNS results, you must enter the command "sudo discoveryutil mdnscachestats". 

For Linux

Generally, the OS doesn't create any DNS cache to store resource records, but the applications are present to provide this service. To display NSCD status, you have to enter the command "service nscd status". 

At this point, we believe you got a clear idea of how important it is to clear DNS cache to improve performance and safety. Now, let's take a look at different methods used to clear DNS cache. 

For Windows 

If you are using a machine that runs on Windows operating system, it is very simple for you to clear cache memory. It takes only a single command to be entered into the command prompt window. So, once you have opened the command prompt, make sure to copy the following command and press enter: 

ipconfig /flushdns

If the system cleared the memory, it would display a message- "Successfully flushed the DNS Resolver Cache." After the DNS cache is cleared, you can go back to the website and see if it's responsive or not. If clearing cache doesn't resolve the problem, then your Internet connection might be unstable. 

For MAC

The command used for MAC OS is- "sudo dscacheutil -flushcache;sudo killall -HUP mDNSResponder." This needs to be entered in the Terminal app, and the difference between clearing cache in MAC and windows is that the command keeps changing for MAC OS. The command mentioned above is for modern Apple products that run OS X lion or macOS Big Sur. If you are using an Apple machine that runs on OS X 10.10.1 and later, you need to use the following command: 

"sudo discoveryutil udnsflushcaches;sudo discoveryutil mdnsflushcaches." The success message will not be reported for MAC, and you need to check if the problem is fixed or not. 

Even though DNS cache is not the whole part of DNS services, it is still imperative to reduce loading time and enhance the user web experience. It is an integral part of web browsers and OSs because it facilitates fast and reliable searches. In some cases, the cache memory's resource records can cause some security problems and a significant performance drop. 

That is why it is recommended to flush your DNS cache regularly, if possible. Clearing cache memory helps you avoid DNS spoofing and restricts data collectors from targeting your system. Make sure to check the commands given above and follow the steps for your specific OS.