How to clear the DNS cache in Windows

How to flush DNS cache in Windows
(Image credit: Sofia Wyciślik-Wilson)

When something stops your favorite websites from loading it can be frustrating. But it can also stand in the way of getting important work done, so it's vital to get things up and running again as soon as possible.

One thing that can go wrong is that the DNS cache can become corrupt. This can be thought of like an address book, used by Windows to translate URLs into IP addresses – issues here can stop sites from loading. 

Thankfully, clearing the DNS cache in Windows is something that can be achieved very quickly. While it is not guaranteed to fix your internet issues, it is certainly worth a shot. Here's how to do it.

Tools and Requirements

  • Windows 10 or Windows 11
  • Command Prompt
  • PowerShell

Steps to clear the DNS cache in Windows

  • Restart Windows
  • Clear the DNS cache using the Command Prompt
  • Flush the DNS cache with PowerShell

Step by step guide

1. Restart Windows

(Image: © Sofia Wyciślik-Wilson)

If you can, you could simply restart Windows to have the DNS cache automatically cleared. There is no special technique to this -- you can either opt to restart your computer, or turn it off and on again. It may not be possible to restart immediately, so we'll now look at DNS flushing options that don't involve a restart.

2. Flush DNS from the Command Prompt

(Image: © Sofia Wyciślik-Wilson)

There are numerous other ways to clear the DNS cache, so you can pick whatever works best for you. To use the Command Prompt, hit the Start button, type cmd and when the Command Prompt entry shows up, click Run as administrator and then click Yes in the User Account Control dialog. Type the command ipconfig /flushdns and press Enter. You should see a message informing you that the command was successfully completed.

3. Flush DNS using the Run command

(Image: © Sofia Wyciślik-Wilson)

The same command can be used in the Run dialog if you prefer. Press Windows + R to activate the Run command and type the command ipconfig /flushdns. To run this command as an administrator – which you will need to do – you need to press Ctrl + Shift + Enter. Again, you will have to click Yes in the User Account Control dialog that appears.

4. Flush DNS using PowerShell

(Image: © Sofia Wyciślik-Wilson)

You can achieve the same results with PowerShell, but you will use a different command. Click the Start button, type PowerShell, and click Run as administrator next to Windows PowerShell. Type the command Clear-DnsClientCache and press Enter. Unlike the Command Prompt, PowerShell will not give you confirmation that the DNS cache has indeed been flushed.

5. Create a batch file

(Image: © Sofia Wyciślik-Wilson)

Although it really shouldn't be necessary to clear the DNS cache often, a batch file can be a time-saver. Open Notepad from the Start menu and type ipconfig /flushdns in a blank document. Click File > Save as, select All types from the Save as type drop-down menu and then type FlushDNS.bat in the File Name field. You can double-click the file to execute the command in future.

Final Thoughts

The easiest way to flush the DNS cache by simply restarting Windows, but this is not always convenient. You may have a very good reason for not wanting to or not being able to restart your computer, and this is why it is so helpful to know how to manually clear the cache as we have explained here.

Numerous things beyond your control can impact whether your internet works or not, and it can be a matter of trial and error trying to home in on the culprit. This is why it is so helpful to have tricks such as flushing the DNS cache up your sleeve – you just never know when it might come in handy.

Sofia Elizabella Wyciślik-Wilson
Freelance writer

Sofia is a tech journalist who's been writing about software, hardware and the web for nearly 25 years – but still looks as youthful as ever! After years writing for magazines, her life moved online and remains fueled by technology, music and nature.

Having written for websites and magazines since 2000, producing a wide range of reviews, guides, tutorials, brochures, newsletters and more, she continues to write for diverse audiences, from computing newbies to advanced users and business clients. Always willing to try something new, she loves sharing new discoveries with others.

Sofia lives and breathes Windows, Android, iOS, macOS and just about anything with a power button, but her particular areas of interest include security, tweaking and privacy. Her other loves include walking, music, her two Malamutes and, of course, her wife and daughter.

You can find her on Twitter and Mastodon.