Although your system flushes the DNS automatically after the expiry of TTL, you can also clear it manually to troubleshoot the network related issues. Flushing the DNS will help you get rid of all the DNS records in your local cache.
DNS flushing is commonly carried out to troubleshoot issues like 404 errors or other DNS-related issues like DNS spoofing or DNS cache poisoning. It also helps to protect your privacy and provides you with an updated version of the website.
In this article, we will first try to understand what a DNS server is. Then we will see when the flushing is required and finally round up the article with methods to manually flush your DNS in both Windows 10 and 11 OS.
What Does Flushing the DNS Do?
A DNS(Domain Name System) is basically a directory of the location of domains/websites on the internet. Like a phonebook, it stores information about a domain and its IP address. An IP address is a device’s location on the internet, and the domain name is a label for the IP address. The internet uses IP addresses to locate other devices.
When you visit a web page, the IP address of that web domain is saved into your cache along with its Time-To-Live(TTL). The TTL denotes how long the DNS information stays in the cache before it expires.
When you look up a website on your computer, it checks the local cache for the IP address of that website. If it finds the DNS information in the cache, it won’t have to go through the DNS lookup process on the ISP’s recursive DNS server. This saves time and resources resulting in faster loading times.
However, if it does not find it in the cache, it will request the DNS server for the address. It will then store the IP information it acquired from the server in the cache for future use.
When you flush the DNS, it will clean out all records in the cache. So, now your PC must repeat the process of requesting the DNS server and saving it in the cache for every site.
When to Flush DNS?
We know that the DNS cache is the record of domains and their IP addresses. So, if this cache is corrupt, your PC won’t be able to use it correctly, leading to connection errors. DNS flushing is usually done to solve these errors. But there are also some other uses for it.
- Corrupted DNS Cache: If the entries in the DNS cache are corrupt, your PC won’t be able to check the IP addresses. This may lead to some websites not working at all or showing 404 errors.
- Changed IP Address: If the website changes servers, its IP address will also change. But the IP address stored in your cache may still point to the old location due to the high TTL value set up by the site owner. It may sometimes result in the older version of the website.
- Avoid DNS Spoofing: Hackers may sometimes manipulate the IP addresses, so if you try to open a certain website, it will open the wrong web page. This process is known as spoofing or cache poisoning. Flushing your DNS will remove such altered data and replace it with a newer record the next time you visit the website.
How to Flush DNS on Windows?
Since Windows clears out the cache periodically, there is no direct option to clear the DNS cache. But you can use commands to do it manually. Here are some methods for manual cache clearing:
Using Command Prompt
The command prompt is the Command line interface of the Windows OS. You can use special command lines here to operate your computer. However, some advanced functions require the command center exclusively to execute.
Flushing the DNS also requires you to use a command. Here are the steps on how to do it:
- Press Win+R, type
cmd, and press Ctrl + Shift + Enter.
ipconfig /flushdnsand press Enter. This will clear the DNS cache of your PC.
Using Run Program
You can also use the Run command to directly execute the
flushdns command. Using the Run program can be more convenient than other methods, but you will have to use an exact command. A misplaced spacebar can also show an error. Here are the steps to do it:
- Press Win + R to open the Run program.
- Copy and paste the following command and press Enter.
This will not show any confirmation that the DNS flush was successful or not. However, you may notice an instantaneous flash on your screen. You can take this as an indication that the DNS flush was successful.
Windows PowerShell is another Command line interface on your PC. The PowerShell allows you to operate even more advanced settings on your PC. Follow these steps to learn how to do it:
- Press Win + X.
- Select Windows PowerShell(Admin). This will require you to provide administrator privileges.
Clear-DnsClientCacheand press enter to clear the DNS.
Using a Batch file
If you frequently need to flush the DNS, you can create a batch file and save it on your desktop. A batch file is an executable program that automatically executes any given command. Simply double-clicking on the file will clear the DNS cache on your PC. Here’s how you create it:
- Right-click on your desktop and go to New > Text document.
- Type the following in the notepad:
@echo off ipconfig /flushdns Pause
- Click on File and select Save as.
flushdns.batin the name bar. You can use any name you like as long as you save it with a “.bat” at the end of it.
- Navigate to the desktop or your preferred location and press Save.
How to Flush Browser DNS Cache?
In addition to the DNS cache of your operating system, some web browsers also maintain a separate DNS cache. Such browsers prioritize their own cache over the system. So, if you’re having any connectivity issues, you will have to clear the browser’s DNS cache instead.
Chrome is one of the few web browsers that have a separate DNS cache. You can directly access the DNS cache from the address bar. Here are the steps to do it:
- Open the Chrome browser and open a new tab.
chrome://net-internals/#dnsand press enter.
- Press the Clear host cache button.
Although Firefox also has an exclusive DNS cache, it clears it out whenever you quit the browser. However, you can also clear the DNS cache manually without closing the browser. Here’s how:
- Open the Firefox browser.
about:networking#dnsand press Enter.
- Click on Clear DNS cache.