- Command Prompt:
ipconfig /flushdns
- PowerShell:
Clear-DnsClientCache
Are you encountering internet connection issues or facing trouble accessing a website? It may be due to DNS corruption or dumping in your Windows PC. In this tutorial, we’ll discuss 6 methods to flush or clear the DNS cache in Windows 11 and 10. Before we dig into the various ways to flush the DNS cache, let’s learn what it is and how it works.
Domain Name System translates human-readable domain names (like www.example.com) into IP addresses (like 192.0.2.1). When you visit a website, your computer sends a request to a DNS server asking for the IP address associated with the domain name. The server responds with the requested IP address, and your computer loads the website. DNS caching is used to speed up the process of resolving domain names to IP addresses.
So, why and when do we need to clear the DNS cache? There can be many answers to this question but the most common reasons are:
- The cache has corrupted or it’s out of date.
- The DNS settings for a domain have been recently changed.
- If a website has moved to a different server and it’s not loading properly.
- Clearing the DNS can also fix the “404 Page Not Found” error in some cases.
- If you want to view the most up-to-date version of a website.
If you’re having trouble connecting to a website or service, one of the first things you can do is flush your DNS cache. This will reset your saved information and fetch new data from the server.
1. Using Flush DNS Command in CMD
If you want to clear your DNS cache on Windows, you can do so by using the Command Prompt. Follow these steps:
- Open a Command Prompt window.
- Execute the following command in the Command Prompt window.
ipconfig /flushdns
- When the DNS record is cleared, you’ll get the following output in the CMD window.
Windows IP Configuration Successfully flushed the DNS Resolver Cache.
That’s it!
2. Using DNS Cache Command in PowerShell
You can also clear the DNS record in Windows 10 and 11 using a PowerShell command.
- Launch a PowerShell window.
- Type or paste the following command in the PowerShell window.
Clear-DnsClientCache
- Once you hit Enter, your DNS cache will be cleared and you’ll be good to go.
3. Using Flush DNS Command via the Run Dialog
Another quick way to clear the DNS in Windows involves using the Run dialog box. Here’s how to do it.
- Open the Run dialog box on your PC. You can do so by using the Windows + R keyboard shortcut to launch it.
- When the Run dialog is launched, type or paste the following command in the text box next to Open.
ipconfig /flushdns
- Now, click the OK button. If you want to run the
ipconfig /flushdns
command as an administrator, press Ctrl + Shift + Enter keys after typing the command in the Run dialog.
4. Flush DNS using a Batch File
Flushing DNS via a batch file might seem complicated but it works flawlessly. The good thing about this method is if you create a batch file once, you run it whenever you want to managee the DNS. Here is how to do it.
- Open the Notepad app. You can find it among the pre-installed apps on your PC. You can also use the Windows Search feature and type Notepad to find the app quickly.
- Now, type or paste one of the following entries in the Notepad file.
ipconfig /flushdns
or
cmd.exe /k ipconfig /flushdns
- Click File > Save or press Ctrl + S keyboard shortcut to save the file.
- When the Save as window pops up, click next to Save as type and select All files(*.*).
- Next, type FlushDNS.bat, ClearDNS.bat, or any other name (with ‘.bat‘ extension) that you prefer in the File name section and click the Save button.
- Navigate to the FlushDNS.bat or ClearDNS.bat file and double-click it.
- Doing so will launch the Command Prompt and execute the
ipconfig /flushdns
command.
5. Flush DNS Automatically via Registry
Using the Windows Registry editor hack below, you can schedule the flushing or clearing of the DNS cache. Let’s see how we can do this.
Warning: Before you proceed with the steps below, please create a system restore point and back up your registry settings using File > Export… in the Registry Editor window.
- Open the Registry Editor and navigate to the following path. Alternatively, you can paste the following path into the address bar of the Registry Editor window and press the Enter key to get to that location.
Computer\HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Dnscache\Parameters
- Right-click an empty area in the right-hand pane and select New > DOWRD (32-bit) Value.
- When the new DWORD file is created, name it “MaxCacheTtl“.
- Now, right-click MaxCacheTtl and select Modify to edit its properties.
- Change the Value data to 86400Â or 172800 (seconds) to clear the DNS cache automatically every 24 or 48 hours respectively. You can set this value as per your preference. Click on the OK button to save the changes.
- Now, right-click an empty area again and select New > DOWRD (32-bit) Value.
- This time, name this new file MaxNegativeCacheTtl.
- Double-click MaxNegativeCacheTtl, modify its Value data to 5, and click OK to save the changes.
You have successfully scheduled the automatic DNS flush on your Windows computer every 24 or 48 hours.
6. Stop DNS from Heaping up via Control Panel
Using this bonus tip, you can configure your Windows PC so the DNS cache doesn’t overpopulate. This way, you can avoid issues caused by the DNS dump.
- Open the Control Panel.
- Click Network and Internet > Network and Sharing Center.
- On the left-hand side of the window, click Change adapter settings.
- Right-click your active network connection and select Properties.
- Select Internet Protocol Version 4 (TCP/IPv4) from the list of items and click Properties.
- Under General, check the box next to Obtain an IP address automatically and uncheck the box next to Use the following DNS server addresses.
- Click OK to save your changes.
- Close the Control Panel window and restart your computer for the changes to take effect.
We hope this article helped you understand what flushing DNS means and how to do it quickly and effectively in Windows 10 and 11. Now that you’ve learned how to flush your cache, take some time to explore how to clear browser cache and cookies in Chrome, Edge, Opera, and Firefox web browsers.