Share this Post
If you’re blocked by certain websites or simply unable to connect to them for whatever reason, clearing your local DNS - also called “flushing” it - may help solve the problem.
Here’s how to do that on Windows, Mac, and Linux.
What is a DNS Cache?
A DNS cache- short for Domain Name System cache - is like a temporary directory where the history of your attempted visits or recent visits to various domains or websites is stored. This database is primarily maintained by the operating system (OS) of your computer.
In short words, it is like a temporary memory of your surf behavior (recent DNS visits) created for quick reference whenever you revisit the website. However, erasing this cache regularly is quite essential.
Why Is That?
In this guide, we are going to learn what DNS cache is all about, why you need to clear DNS cache and how it helps you browse the internet unobstructed.
Table of Contents:
The Main Purpose of DNS Cache
DNS servers generally convert the domain names into IP addresses whenever you are web browsing. By default, each time you try to access a website, the browser will take a detour to DNS servers and ask for the corresponding IP address of that domain name.
If you are still a bit unsure and in need of further assistance check out our guide on what is a domain name for more information.
This happens every single time you try to access a website by its domain name. The entire process is time-consuming, and thus causes slow website load times.
“DNS Server Not Responding”
Look familiar? Chances are you’ve seen this before (and maybe you’re seeing it right now!).
Moreover, if a site is experiencing high traffic, the DNS servers might experience an overload and show above mentioned error. That’s when the DNS cache comes in!
A computer’s OS (Mac OS or Windows or Linux) will create temporary DNS caches for faster name resolution. This database stays valid for a certain period of time.
Within this time, the browser can access the website simply by looking up the DNS cache of your operating systems, rather than connecting to the network’s DNS server. This assists in faster load times.
Yet, there are many valid reasons to frequently flush your DNS, few of them being the protection of your surf history and avoiding technical errors. Flushing your DNS is an important prevention - you won't have to learn how to fix the DNS server that is not responding.
How DNS Cache Actually Works?
Whilst surfing the web, whenever you try to access a website, your computer’s system will intercept and search for the domain name you’re trying to access in the temporary DNS cache database.
In this database, you’ll find a memory of all recently visited website domain names along with their calculated IP addresses and other important parameters.
What is DNS Cache Poisoning?
DNS caches might get poisoned when viruses or other cyber-attacks insert unauthenticated IP addresses or unauthorized domain names into the DNS cache database.
Sometimes, it also might get polluted due to the system’s administrative or technical issues.
When this happens, the browser will get redirected to an incorrect domain name, which is generally a malicious site or a site stuffed with ads.
This in turn threatens well-known websites, as clients might face phishing attacks if they’re redirected to a similar looking but scamming site and they fail to analyze it.
What is DNS Flushing?
DNS Flushing is when your computer administrator clears the DNS cache from the system. This is usually done when you are facing troubleshooting issues, cache poisoning, or problems in internet connectivity.
Flushing DNS will delete all the cache entries. When you visit websites, new entries will automatically be fed in the DNS cache database, taken from your network’s DNS server.
Why do you need to do DNS Flushing?
Protection From Manipulation
Erasing DNS cache regularly will prevent cyber attackers from accessing the entries in your DNS cache database. If you don’t clear it, the data stored in DNS cache can be altered or even changed.
In this case, every time you access a particular domain name, you might get redirected to a phishing site instead. Such DNS poisoning is often carried out by cybercriminals to steal online banking log-in details and other such sensitive information.
Protect Search History
Not just IP addresses or validity, but there are many other important parameters stored in DNS caches that can give a complete overview of your search history. Cleaning DNS cache will save you from revealing yourself too much to such web applications.
Tackle Technical Issues
A simple DNS flush on your OS, be it Mac OS, Windows or any other will most probably solve technical errors that usually occur when you want to access a web app.
Generally, this happens when an old IP address or wrong IP address is stored in the database.
Thus, clearing the DNS cache will allow the browser to once again connect with the DNS server and get updated IP address.
What Parameters Are Stored in the DNS Cache?
All the entries in the DNS cache database are referred to as RR (“resource records”) and viewed in ASCII code.
Various other parameters including IP addresses are fed into the database, such as resource data (hostname), record name, record type, time to live (validity of the record), and so on.
What Happens When You Don’t Flush DNS?
If you do not erase DNS cache regularly, all the entries stay as they are until their TTL (Time To Live) finishes.
How to clear the DNS cache?
The process of flushing DNS varies from OS to OS. Here are some of the instructions that can help you clear DNS cache from different operating systems:
Clear DNS cache in Windows
To clear the DNS cache in Windows follow the steps below:
- Close all tabs in the browser
- Press ‘Windows’ icon key and ‘R’ key together on the keyboard
- Type cmd in the given text box and click OK
- Type ipconfig /flushdns on the Command Prompt screen
- Press Enter
Clear DNS cache in Mac OS
DNS flushing methods for Mac OS keep on changing with time. This process varies based on which version of macOS you’re running.
For macOS version 10.5, open your terminal and run the following command to clear the DNS cache:
sudo lookupd -flushcache
For macOS version 10.6, open your terminal and run the following command to clear the DNS cache:
sudo dscacheutil -flushcache
For macOS version, 10.7, 10.8 and 10.9, open your terminal and run the following command to clear the DNS cache:
sudo killall -HUP mDNSResponder
For macOS version 10.10, open your terminal and run the following command to clear the DNS cache:
sudo discoveryutil udnsflushcaches
For macOS version 10.11 or above, open your terminal and run the following command to clear the DNS cache:
sudo killall -HUP mDNSResponder
Clear DNS cache in Linux
By default, the DNS caching application is not installed in most Linux operating systems so they do not use a DNS resolver cache. However, if any DNS caching application is installed.
Then, you can clear the DNS cache by running the following command in your terminal:
sudo /etc/init.d/dns-clean restart
sudo /etc/init.d/dnsmasq restart
sudo /etc/init.d/nscd restart