How To Flush DNS Cache On Linux 2022 Tip

This tutorial is about how to flush DNS cache in Linux. We will do our best for you to understand this guide. I hope you will like this blog How to Flush DNS Cache in Linux. If your answer is yes, please share after reading this.

Check how to flush DNS cache in Linux

Troubleshooting your website can be a daunting responsibility. When it comes to tasks like flushing the Domain Name Server (DNS) cache, it’s easy to get overwhelmed and confused before you even begin. Luckily, you can accomplish this particular task quickly and easily, even without technical experience. In two short steps, your DNS cache will be cleared and you can continue working to resolve any issues you are facing.

In this article, we’ll explain what a DNS cache is and when you might need to clear your cache. We’ll then share a real-life example from our first-hand experience and explain how to perform this troubleshooting step, no matter what hardware you’re using.

What is DNS caching?

Like web browsers, operating systems also store cache files from previous Domain Name System (DNS) lookups in what is called the DNS cache. It consists of compressed information units called Resource Records (RR) about all visited websites, displayed in ASCII code.

Here are the components of a DNS cache:

  • resource data ‒ contains the description of a record, such as address and hostname.
  • register type ‒ describes the type of record (A or AAAA record).
  • record name ‒ displays the domain name of the DNS entry.
  • Lifetime (TTL) ‒ the validity period of the resource record measured in seconds.
  • To classify ‒ the appropriate protocol group from the resource record.
  • Resource data length ‒ refers to the resource data value.

When visiting a website for the first time, the user’s operating system stores that site’s DNS cache files. It speeds up the DNS lookup process by resolving domains to their IP addresses, which makes web pages load faster the next time you visit the same IP address.

Reasons to Periodically Flush the DNS Cache

Most operating systems perform DNS caching to reduce the load on DNS servers during high traffic. Its TTL determines the validity period of the cache. As long as the cache files are still valid, they will respond to content requests without going through the DNS server.

Despite this, using corrupted or outdated DNS cache files can lead to bugs and security vulnerabilities. Your operating system may store a bad DNS cache when you visit websites that have just migrated to a new domain or hostname. Therefore, we recommend that you flush your DNS cache regularly.

Here are the reasons why you should regularly flush your DNS cache:

  • To prevent tracking of browsing behavior ‒ Storing DNS records makes it easy for hackers to predict your browser history.
  • Security ‒ DNS cache files are the primary target of DNS spoofing, putting sensitive user information such as login credentials and personal data at risk.
  • To solve technical problems ‒ Forcing the operating system to check for updated DNS records can resolve connection issues and incorrect display of web content.

Ways to flush DNS cache

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


In Microsoft Windows, flushing the DNS cache is a relatively simple process. Note that you must run as administrator when running the command prompt to access all system security permissions. Here are the steps to flush DNS cache in Windows XP, 7, Vista, 8, 8.1 and 10.

  • Simultaneously press Windows + R keys or right-click on the Windows Start menu and click Run. Type cmd to open Windows command prompt console. If you do not have administrator privileges yet, run the cmd command by pressing Ctrl+Shift+Enter.
  • Type ipconfig /flushdns at the command prompt and press Enter. This command will clear the DNS cache files on your computer and reset the DNS resolver cache.
  • If the process is successful, you will see the confirmation message in your command prompt as follows:


By default, Ubuntu does not cache DNS records. If you are manually installing a DNS service such as the Name Service Caching Daemon (nscd), the steps below will show you how to flush the DNS cache on your computer. Be sure to run as administrator when following these steps.

  • Press the Ctrl + Alt + T keys simultaneously to open the terminal window.
  • Enter the following command line to clear the DNS cache files in the init.d subdirectory:

restart sudo /etc/init.d/nscd

Here is the guide to flush DNS cache on a system using systemd.

  • Press the Ctrl + Alt + T keys simultaneously to open the terminal window.
  • Type the following command line:

systemd-resolve –flush-caches

Enter the following at the command prompt to check if the above command flushed the DNS cache correctly.

systemd-resolve –statistics

Mac OS X

Although the steps to flush a DNS cache on Mac OS X are simple, you need to run the correct DNS flush command based on your current version of OS X.

  • Press the F4 key, then type terminal in the Launchpad search field to open the command terminal window.
  • If you are using Mac OS Sierra, X El Capitan, X Mavericks, X Mountain Lion, or X Lion, the next step is to type the following at the command prompt:

sudo killall -HUP mDNSResponder

  • To flush the DNS cache on Mac OS X Yosemite, type the command:

sudo discoveryutil udnsflushcaches

  • If you are using Mac OS X Snow Leopard, use the command:

sudo dscacheutil -flushcache

  • For Mac OS X Leopard and earlier, enter the following command to flush the DNS cache:

sudo lookupd-flushcache

  • To flush the DNS cache on Mac OS X High Sierra, type this at the command prompt:

sudo killall -HUP mDNSResponder

  • Here is the command to flush DNS cache on Mac OS X Mojave:

sudo killall -HUP mDNSResponder

  • If you are using Mac OS X Catalina, use this command:

sudo killall -HUP mDNSResponder

  • Here is the command to flush DNS cache in Mac OS X Big Sur:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

Clear your DNS cache in Google Chrome

Since Google Chrome stores a separate operating system DNS cache on your computer, clearing them will have the same benefits. This is especially important if you use Google Chrome as your primary web browser. Note that this type of cache is different from the browser cache. Here are the steps to do so:

  • Open Google Chrome and enter the following address in your address bar:


  • On the Internal Network Settings page, select Clear Host Cache.

Final Words: How to Flush DNS Cache in Linux

Hope you understand this article How to Flush DNS Cache in Linux, if your answer is no, you can ask anything via the contact forum section linked to this article. And if your answer is yes, share this article with your family and friends.

Previous EU wants its own DNS resolver that can block 'illegal' traffic *TorrentFreak
Next The European Commission wants a DNS built and offered by the EU