Suppose, you want to visit one of your friends named Jack. You don’t know exactly where he lives. Hence, you need to find the address in your notebook. It will take some time to find that name and then his address. Instead, if you write down that address on a sticky note and attach it to your desk, it will take less time to find out the address than finding it in your notebook.
Your local DNS cache works exactly the same way. When you search for a website, your browser searches that address on your local DNS first. If it matches then you get redirected to the website you were seeking for. And if that address isn’t in your local DNS cache, then your browser searches in other DNS caches. Which takes a bit longer time to redirect you to that website.
Still, confused? No worries! Let us explain it more in the next paragraphs.
And more importantly, we are going to show you why you need to clear your DNS cache and how you can do that. So, stick with this article to know everything about the local DNS cache.
What is DNS Cache and How DNS Cache Works
DNS stands for Domain Name Server. It’s an index of all the websites on the internet and their IP addresses. You can imagine it as a phone book or directory for websites. When you type a domain name, such as www.wphive.com, into a browser, the name has to be translated into an IP address before the results are displayed. DNS servers perform this conversion from name to IP address, and vice versa.
With many DNS servers available on the internet, it can take a while to get a response. To make this process faster, operating systems create their own cache for website addresses with the domain name server (DNS) information of each website you visit.
The domain name server information is-
- Resource Data: This describes the record. For example, it identifies the host name or address.
- Record Type: This refers to the type of entry. The “A” record type is what contains the IP address for the host name.
- Record Name: This is the optional value of the object’s domain name.
- Time to Live (TTL): TTL is an optional value to indicate how long the resource record is valid, displayed in seconds.
- Resource Data Length: This is an optional field to store the length of the resource data.
When you enter a domain name in your browser, it looks for the DNS information in the local cache first. If it finds the information in the local cache, it uses this information to redirect to the website.
On the contrary, if it doesn’t find the information in the local cache, the browser searches the information from other DNS caches across the internet. This takes time to visit any website.
This is how a DNS cache works.
Why It’s Important to Clear DNS Cache
DNS cache is a good thing, right? So, why on earth someone would clear DNS cache?
Well, there are certain reasons behind clearing the DNS cache.
- Outdated Information: You local cache server may contain outdated information. If the domain name in the cache points the old or incorrect ID adrress, you won’t get the correct information. Clearing your browser history won’t be a solution for this problem. Instead, you can flush your DNS cache to get rid of this situation.
- Privacy Threat: As your local DNS cache store the information of all the websites you visit. So, if anyone get the access to your DNS cache, it could be disastraous for you. As a result, clearing DNS cache after a certain time is a good practice.
- DNS Poisoning or Spoofing: It’s possible for cybercriminals to access the cache and insert or change the IP addresses. This is called DNS poisoning or DNS spoofing, and it can redirect you to a website designed to gather sensitive data, such as passwords to online accounts.
For companies relying on the internet to do business, it’s critical to maintain proper security and keep things running smoothly. Clearing the DNS server will remove any invalid addresses, whether because they’re outdated or because they’ve been manipulated.
How to Flush DNS Cache- A Step by Step Guide
Clearing DNS cache is simple as pie. In this tutorial, we are going to show how you can clear your DNS cache from multiple platforms like macOS, Windows, Linux, and Chrome.
- How to Clear DNS Cache on macOS
- How to Clear DNS Cache on Windows
- How to Clear DNS Cache on Linux
- How to Clear DNS Cache on Chrome
Let’s start with the macOS.
1. How to Clear DNS Cache on macOS
To clear your local DNS cache, at first, you need to know which macOS version you are currently using.
- To figure out your operating system version, click on the ‘Apple’ icon in the top-left corner of your desktop, and select About This Mac.
- You will see the macOS version like the following image.
After knowing the OS version, open your Terminal.
- To open the terminal, click Command + Space button at a time.
- Type terminal to open it.
Note: If you’re unable to open Terminal through Spotlight, navigate to Go > Utilities > Terminal or click Applications, open the Utilities folder, and then double-click Terminal.
Then run the following command for Mojave version.
sudo killall -HUP mDNSResponder
You’ll be prompted to enter your computer password.
After you’ve done so, your DNS cache should be clear.
Commands for macOS Different Versions
If you’re using other than macOS Mojave, you should follow the below code.
The table below lists the commands for clearing the DNS cache on most macOS versions. You can copy and paste them directly from the table into your terminal.
|macOS Versions||Terminal Command|
|Mojave (version 10.14)|
High Sierra (version 10.13)
Sierra (version 10.12)
Mountain Lion (version 10.8)
Lion (version 10.7)
|El Capitan (version 10.11)|
Mavericks (version 10.9)
|Yosemite (version 10.10)|
|Snow Leopard (version 10.6)|
Leopard (version 10.5)
|Tiger (version 10.4)|
2. How to Clear DNS Cache on Windows 10
To clear your DNS cache on Windows 10, you’ll need to open Command Prompt, the system’s command-line interface.
- Load the Command Prompt as an administrator. Open the Start Menu and start typing command prompt until you see it in the results.
ipconfig /flushdnswhen the prompt loads and hit Enter on the keyboard.
- The process should take only a few seconds. You should see the DNS Resolver Cache confirmation message when it’s done.
To clear DNS cache from Windows 8, 7, and XP, use the same command line.
3. How to Clear DNS Cache on Linux
Linux works a bit differently than Windows and macOS. Unlike Windows and macOS, each Linux distribution might use a different DNS service. Some distributions, like Ubuntu, don’t have a default DNS service at all.
Some of the distributions are NCSD (Name Service Caching Daemon), dnsmasq, and BIND (Berkely Internet Name Domain). For every distribution, you need to launch a terminal window. Press Ctrl+Alt+T on your keyboard and use the following command to clear the DNS cache.
- To flush local NCSD DNS cache, enter the following command.
sudo /etc/init.d/nscd restart
- To flush local dnsmasq DNS cache, use the following command.
sudo /etc/init.d/dnsmasq restart
- To flush local BIND DNS cache, try the following command.
sudo /etc/init.d/named restart sudo rndc restart sudo rndc exec
Note: Enter your password again, if the terminal asks you to. You will see the response when the service stops and starts again.
4. How to Clear DNS Cache from Your Browsers (Chrome, Firefox, & Safari)
Let’s learn how to clear DNS cache from your browsers. In this part, we are going to show you how you can clear DNS cache from Chrome, Firefox, and Safari.
If you want to clear DNS cache from your Chrome browser, open your Chrome browser and then search the following command into the address bar.
Now click on the “Clear host cache” option.
This should clear your Chrome browser DNS cache.
To clear DNS cache from your Firefox browser, open a new tab in Firefox and enter the following command in the address bar, and press enter.
This page should show you DNS cache details and offers a button
Clear DNS Cache, click on it to clear the browser’s DNS cache.
Safari has a hidden option to clear different caches, including DNS, from its menu bar. But first, you would need to enable Develop menu.
- To do that, go to Safari menu and then open Preferences.
- Then click on the Advanced tab and then check Show Develop menu in menu bar.
- Now you should see a new option, Develop in Safari’s menu bar.
- In that menu, select Empty Caches option to clear the browser’s cache, including any caches related to DNS.
Now, the DNS cache from your Safari browser should be cleared.
Frequently Asked Questions on How to Clear DNS Cache
There is a set of common questions that people often ask about clearing DNS cache. We have tried to address those questions in this section. Let’s check our answers.
Is it safe to clear DNS cache?
Yes, it’s safe to clear DNS cache on a regular basis. Because the DNS cache can sometimes carry outdated or incorrect information. So, it’s necessary let alone safe to clear the DNS cache after a certain time.
What does clear DNS cache mean?
Clear DNS cache means you clear all the information that your local DNS server saves for you every time you visit a website. After cleaning the DNS cache, it again starts to store the information while you visit new websites.
Does a restart flush DNS cache?
No. Computer restart doesn’t flush the cache from your operating system and browser. However, restarting your internet router can flush the cache.
How long does DNS cache last?
By default, Windows stores positive responses in the DNS cache for 86,400 seconds (1 day) and stores negative responses for 300 seconds (5 minutes). You can change this time period if you want to.
Is cleaning cache good or bad?
Cleaning cache after a certain time is good. Because it removes the outdated information from the DNS cache. And it is also helpful to protect your site from DNS poisoning or DNS spoofing.
Clear Your Local DNS Cache Regularly to Keep Your Site Safe
Now you should know everything about DNS cache. It’s true that your local DNS cache facilitates the website searching experience. On the other hand, it’s also important to clear your local DNS cache regularly to protect your site from hackers and spammers.
Follow this step by step tutorial and clear your local DNS cache all by yourself. You don’t need to hire any expertise to do that task.
If you face any complications while clearing your local DNS cache, let us know through the comment box below. We would love to help you out at our earliest convenience.