How to Flush DNS Cache

How to Flush DNS Cache

If you have connection issues, flushing your domain name system (DNS) cache could be the solution you need. However, while a DNS cache can speed up loading times, it might also pose security risks.

Each operating system requires a different process to flush the DNS cache. This tutorial will guide you through the steps on Windows, macOS, and Linux versions. We’ll also show you how to do it in Google Chrome.

Lastly, we’ll explain the benefits of regularly flushing your DNS cache.

Video Tutorial

Learn how to flush DNS cache and improve your security and connection with our video tutorial.

Subscribe For more educational videos! Hostinger Academy

What Is DNS Cache?

DNS cache is a temporary storage of previous DNS lookups in your operating system. When searching for a specific address online, your web browser and operating system will cache the IP address and DNS records.

This method streamlines the DNS lookup process by resolving domains to their IP addresses, making web pages load faster for the next visit. A DNS cache consists of compressed information units called resource records (RR) about all visited websites, displayed in ASCII code.

The following are DNS cache’s components, which is often found in the DNS Zone Editor:

  • Resource data ‒ contains a record’s description, such as the address and hostname.
  • Record type ‒ describes the record’s type (A or AAAA record).
  • Record name ‒ showcases the DNS entry’s domain name.
  • Time-to-live (TTL) ‒ resource record’s validity time measured in seconds.
  • Class ‒ resource record’s appropriate protocol group.
  • Resource data length ‒ refers to the resource data’s value.
Hostinger web hosting banner

How to Flush DNS Cache

Depending on your operating system, the steps to flushing a DNS cache may vary. The tutorial below will show you how to do it on Windows, Linux, and Mac OS X.

How to Flush DNS DNS Cache in Microsoft Windows XP, 7, Vista, 8, 8.1 or 10

With Windows, the process to flush your DNS cache will be the same for most versions. Keep in mind that you need to use the Run as administrator option when executing the command prompt to access all system security permissions:

  1. Use the Windows + R shortcut to open the Run window.
  2. Type cmd to open Windows Command Prompt.
  3. Type the following command and hit Enter:
ipconfig /flushdns
  1. Windows will automatically clear your DNS cache files and reset the DNS resolver cache. If the process is successful, you’ll see the following confirmation message in your Command Prompt console:
Select Command Prompt Microsoft Windows

Important! Run the cmd command by pressing Ctrl + Shift + Enter to use the Run as administrator option more quickly. Please note that you will need admin rights to do so.

How to Flush DNS Cache in macOS 11 Big Sur, 12 Monterey, and Older Versions

With macOS, make sure to run the correct flush DNS command based on your current OS version. Therefore, the first step is to check your macOS version by clicking on the Apple icon -> About This Mac.

Next, open the command terminal window by pressing the F4 key and entering terminal in the Spotlight search field. Then, insert the command specific to your macOS version and press Enter. If prompted, insert your admin password and click Enter key again to clear your DNS cache.

Here are the specific commands for each version:

macOS 11 Big Sur or 12 Monterey:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

macOS 10.11 El Capitan, 10.12 Sierra, 10.13 High Sierra, 10.14 Mojave, or 10.15 Catalina:

sudo killall -HUP mDNSResponder

macOS 10.10 Yosemite:

sudo discoveryutil udnsflushcaches

macOS 10.7 Lion, 10.8 Mountain Lion, or 10.9 Mavericks:

sudo killall -HUP mDNSResponder

macOS 10.6 Snow Leopard:

sudo dscacheutil -flushcache

macOS 10.5 Leopard:

sudo lookupd -flushcache

How to Flush DNS Cache in Linux

Unlike Windows and macOS, Ubuntu does not cache DNS records by default. If you manually install a DNS service, you will need to flush the DNS cache on your computer.

To clear your DNS cache using Linux, press Ctrl + Alt + T keys together to open the Terminal application.

In the terminal window, enter the required command based on the service your Linux system is running. Here are the commands for Name Service Cache Daemon (nscd) and systemd.

How to Flush DNS Cache With nscd

Enter the following command line to clear DNS cache files on the init.d subdirectory:

sudo /etc/init.d/nscd restart

How to Flush DNS Cache With systemd

Use the following command line:

systemd-resolve --flush-caches

Then, enter the following command to check whether the previous command has successfully flushed the DNS cache.

systemd-resolve --statistics

How to Flush DNS Cache in Google Chrome

Google Chrome stores a separate DNS cache from the operating system. It is also essential to flush your DNS cache in Google Chrome if it is your default web browser to avoid connection errors.

Important! Keep in mind that this cache type is different from the browser cache.

Here are the steps to flush the DNS cache in Google Chrome:

  1. Open Google Chrome and enter the following line into the address bar:
chrome://net-internals/#dns
  1. Near the Host resolver cache option click Clear host cache.
Host resolver cache, clear host cache Google Chrome

Important! Use edge://net-internals/#dns if you’re using Microsoft Edge.

Reasons to Flush DNS Cache Periodically

Most operating systems perform DNS caching to lessen the DNS servers’ burden during high traffic. Its TTL determines the cache’s validity period. As long as the cache files are still valid, operating systems will answer content requests without going through the DNS server.

However, corrupt or outdated DNS cache files can lead to errors and security vulnerabilities. For example, your operating system may store a bad DNS cache when a site just moved to a new domain or host.

Therefore, here are some of the main benefits of flushing your DNS cache regularly:

  • Prevent search behavior tracking ‒ storing DNS records makes it easier for hackers to track your online searches.
  • Improve security ‒ avoid exposing sensitive information – such as login credentials and personal data – from DNS spoofing.
  • Solve technical problems ‒ forcing the operating system to search updated DNS records can help fix connection issues and incorrectly displayed web content.

Conclusion

When experiencing connection issues or seeing incorrectly displayed web pages, your system might be storing corrupted or outdated DNS cache records. You can quickly solve it by using flush DNS command. If doing so doesn’t resolve the problem, try to clear your web browser cache instead.

We hope you find this article helpful in solving DNS server issues. Good luck.

How to Flush DNS Cache FAQ

Is It Safe to Flush DNS Cache?

Yes – flushing your DNS cache has no negative side effects. All it does is remove any addresses that are outdated or, in another way, invalid.

How Often Should I Flush my DNS Cache?

It takes 15 minutes for DNS cache to fully clear. While there’s no set frequency for DNS cache flushing, we recommend doing it frequently for the best browsing experience.

Does Clearing DNS Cache Speed Up My Internet?

Flushing DNS cache doesn’t greatly affect your internet speed. You’ll get rid of outdated cached data, but it might take a bit longer directly after the DNS cache flush to load different web pages, as the browser needs to re-fetch and re-cache the data.

Does Restart Clear DNS Cache?

Yes. If you reboot the DNS server, all cache is cleared automatically.

Author
The author

Jordana Alexandrea

Jordana is a Senior Content Writer with over 5 years of experience in digital marketing and web development. When she’s not busy with work, she dabbles in creative writing and movie reviewing. Follow her on LinkedIn.

Author
The Co-author

Astari S.

Astari is a digital marketing expert, with a focus on SEO and WordPress. She loves to share her wealth of knowledge through her writing, and enjoys surfing the internet for new information when she's not out in the waves or hiking a mountain. Her mission is to learn something new every day, and she firmly believes that there is no such thing as too much knowledge.