How to Flush DNS Cache Locally in Windows, macOS, & Linux

Photo of author

By Vijay Singh Khatri

If we look at the by default functioning of operating systems, we will observe that most of them cache up the IP address and the Domain Name System (DNS) records. The main reason for creating a cache of these two fields is to provide results of future requests for the same in a much shorter time.

Let’s take an example to explain things more clearly. Suppose you have opened the web address of this page. For the first time, the browser needs to ask the DNS servers where they have to find the site. Once the browser gets the information, it stores that information in its local cache. As a result, the next time you try to access the same URL address, it will not send the request to the server but retrieve the information from its local cache and open the web address instantly.

In caching DNS and IP addresses, the problem arises when there is a corrupt IP address that needs to be removed. On the other hand, a bad DNS cache can also cause your network to destabilize, which leads to errors in your Internet connection. Thus, the operating system does allow you to force flush the DNS and clear out the local cache from your system.

Here, in this article, we are going to show you methods to flush DNS cache, which is locally stored in Windows, macOS, and Linux. Our techniques are pretty simple, and even a layman can perform this task easily.

What is DNS?

DNS is the most integral part of your Internet connectivity, and thus, even if you are an average user of the Internet, you need to know what DNS is. Let’s try to break it down into simple parts. Think of DNS as a phonebook, but instead of providing you with the phone numbers, it maps out the names specified to their computers called IP addresses. Every individual web address has its IP address, and collectively they are called DNS records.

By the number of Internet users, you know it is impossible to fit all the addresses in one place. As a result, DNS is organized in smaller books called zones which are stored in DNS servers. A single DNS server keeps more than one zone. But the range of storing the DNS zones may vary from server to server. Right now, there are more than 600 different root servers that are presented all over the different parts of the world. There are only 13 DNS root server addresses in the world. There are more, but mainly these 13 root servers are used to respond to the queries that are coming from the different root server networks.

Why Do You Need DNS Cache?

As we said earlier, when you flush your DNS, both the IP addresses and the DNS information stored in your browser will be removed. This procedure can help you resolve issues that might be hindering the normal functioning of your network. One thing you need to know is that the DNS will automatically clear itself from time to time without even letting you know about it. This is because DNS cache saves up TTL (time to live) components. This provides information on how long the DNS record is valid.

During this time, if you revisit the same URL, the browser will fetch the information from the DNS cache, no matter how many times you ask for it. Once the record passes its valid time, it will expire, and the browser has to download the updated version of the DNS for that URL address.

When to Flush DNS Manually

Sometimes to resolve some technical issues, you have to flush your DNS cache manually. We have provided here some scenarios, where flushing the DNS manually can help you solve the problem or get rid of the networking issues.

1. Security Reasons

Anyone who has access to your computer will be able to see the information present in the form of a DNS cache. As a result, they can see which websites you are visiting. This can be done using the simple command “ipconfig/displaydns” on the command prompt. But if you clear out the cache manually, it will only show the information which automatically updates in the cache.

2. Removal of Bad Connection

If you are looking for a separate list that shows all the bad IP responses, then you are in no luck. All the lousy IP connections are located in the same list of good ones. Thus, if you have a wrong IP address saved in your DNS cache, then flushing out the non-working IP address will remove the inappropriate entry from your browser. After that, if you try to access that web address, your browser is going to pull a new entry from the server, which works.

There could be several reasons as to why that particular web address was not working; some of the common causes are malware and error in the code of the website, or it could be that the IP address of the web page you are trying to visit has been changed recently and the DNS cache isn’t updated by the same.

3. Technical Errors

If you are experiencing issues with your network and the normal working of the Internet, it might be a good idea to flush down the DNS cache before you access your web applications once again. There could be some outdated entries that are causing the problem and not letting you load the website that you want.

When you delete the DNS cache, your browser will fetch the information from the server, and new information will be loaded in the DNS cache. This will solve your problems, allowing you to get back to stable connectivity.

Steps to Flush DNS Cache Locally in Windows

Flushing out the DNS cache in Windows is quite simple; given below, we have provided three methods for three different versions of Windows that are Windows 10, Windows 8, and Windows 7 / XP.

1. Windows 10

Step 1: Open the command prompt in your Windows 10 by clicking on the Start button present in the bottom left corner of the screen. After that, go to Windows Systems > Command Prompt.

Step 2: Once the command line opens up, type in the following command to flush out the DNS: ipconfig /flushdns and hit the Enter key to initiate DNS flushing.

Now your command prompt will show that the DNS cache has been successfully flushed. You can close the application now and launch your web application.

2. Windows 8

Step 1: To clear out the DNS cache in the older versions of Windows, you have to type in the same command which we have used in Windows 10. But the slight change between the two is how we access the command prompt in Windows 8. In Windows 8, you have to open the Apps screen, which is present in the Windows Systems, and then select the Command Prompt.

Step 2: Once the command prompt launches, you need to write down the following command, and then press the Enter key: ipconfig /flushdns

You will receive the confirmation that you have successfully cleared out the DNS cache from your system.

3. Windows 7 & XP

Step 1: Go to the Start button, and then navigate to All Programs > Accessories, and then find the Command Prompt.

Step 2: Once the Command Prompt opens up, type in the command and press the Enter key: ipconfig /flushdns.

Steps to Flush DNS Cache Locally in Mac

Step 1: Click on the Spotlight, which is in the shape of a magnifying glass on the top right corner of your screen. Or you can press the Command (⌘) + Space keys together to open the search.

Step 2: After that, search for Terminal in the Spotlight and click on the application which comes in the result.

Step 3: Once the Terminal in your macOS is launched, you need to enter the following command: sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

Step 4: Terminal will ask you to provide the system’s password. Type in the password, and then click on the Enter key to clear out the cache.

Note: If you are not able to open up the Terminal from the Spotlight, then what you need to do is navigate to Go > Utilities > Terminal. The other way around getting to the Terminal is by clicking on the Applications, opening up the Utilities folder, and then double-clicking on Terminal.

The older version of macOS uses alternatives for the above command, but all the other steps will remain the same.

  • For macOS El Capitan or newer: run sudo killall -HUP mDNSResponder
  • macOS Yosemite: sudo discoveryutil udnsflushcaches
  • macOS Lion, Mountain Lion, and Mavericks: sudo killall -HUP mDNSResponder
  • macOS Tiger: lookupd -flushcache

Steps to Flush DNS Cache Locally in Linux

Before we proceed, we would like to say that all Linux distros (distributions) don’t function in the same way. Thus, some might have enabled the DNS caching, while others have disabled it. Therefore, before you write the command to flush out the DNS, you should check whether it’s storing data or not.

  • Step 1: Launch the Terminal in Linux OS by clicking on the buttons (Ctrl + Alt + T) together.
  • Step 2: After that, you need to type the following command and then press the Enter key: ps ax | grep dnsmasq. This command will provide the output where you can see if the DNS cache size is zero or not. If it is zero, there is no need to perform the rest of the steps, as there is no information stored in the cache. But if you find some value to the cache size, then follow the next step to flush down the cache.
  • Step 3: To clear out the DNS cache, type in the following command and press the Enter key: sudo /etc/init.d/dns-clean restart

Things to Keep in Mind Before Flushing DNS Cache

To be honest, there is no rule as to when and how you need to flush out the DNS cache. You can do it anytime, or if there is an emergency that requires a mandatory flush of the cache. Moreover, if you somehow have been redirected to the site which you haven’t called, you immediately need to flush your DNS cache to be safe from the spoofing attack, which is based on the manipulated DNS entry. There is no specific time when an attack might happen after you have opened the malware-affected web page, so you need to flush out the DNS at the earliest.

Apart from this, if you have any doubts about whether you want to clear the DNS cache or not, or how it is going to affect your web browsing. Then there is nothing to worry about as there is no noticeable effect of this procedure. As we said earlier in this article, the web browser automatically flushes the DNS cache from time to time. So, if you do manually flush the cache, the only difference you are going to see in your web browsing is that for the first time, the web page may take 10 to 20 milliseconds more to load on your browser fully; that’s all.


So these were some of the methods which can help you remove the false or faulty records of web pages that are stored locally in your DNS cache. Be sure to follow the above-mentioned steps carefully, or else the process will be incomplete, and you will face the same problems and errors. There are many reasons to keep your DNS cache regularly cleaned. Moreover, this practice can keep you secure from phishing attacks.

These were some of the easiest ways to perform DNS flushing no matter which operating system you are working on. We hope this DNS cache flushing tutorial will serve as a ready reckoner in resolving your problem and get you back online.

Leave a Comment