What is a DNS Cache? – Know Why do You Need to Flush DNS

DNS stands for Domain Name System. It is a method to map or translate domain names to their associated IP addresses. When you visit a webpage for the first time, your computer requests the DNS server to translate the domain to its IP address. The computer stores this mapping to your local system as a temporary database. This temporary database is called a DNS cache. You can flush DNS cache if it is poisoned or corrupted.

Why is a DNS cache needed?

The concept of a cache comes from the principle that we are more likely to use similar items repeatedly. When we use the internet, we tend to visit same websites regularly. For instance, some of the most used websites include Facebook, Gmail, etc.


When a query is sent to a DNS server to resolve a domain name, it introduces a lag depending on how far the DNS server is located. To optimise the time taken to load a page your computer creates a local temporary database and populate it with your previously visited domain names and their IP addresses.

You will notice that when you open a web page the second time, it loads much faster than the first time.

How is a DNS cache used?

Every time your browser issues a DNS request, your computer first looks up in the local DNS cache. If an entry corresponding to the domain name is present, it is used to resolve the hostname and load the webpage.

Else, the computer redirects the query to the configured DNS server. The DNS server resolves the hostname and then populate the local DNS cache.

What is DNS cache poisoning?

DNS spoofing or DNS cache poisoning occurs when a hacker maliciously changes the entries in your DNS cache. In this scenario, altered entries cause the name server to return incorrect IP address for a given domain name. Thus, you will be redirected to a different server.

DNS cache gets poisoned by viruses and malicious software downloaded from the internet. Hackers can poison your DNS cache to phish for your personal information such as email, password, bank details, etc.

For example, if a hacker has altered the IP address of your bank’s website, you may be redirected to a different site that looks like your bank’s website. If you enter your account information on the fake website, it gets stored and can be used to steal your money.

Alternatively, your domain name server cache can get corrupted due to technical glitches or administrative faults. A corrupted domain name server cache will likely lead to connectivity issues with web pages not loading.

How to fix a corrupt or poisoned DNS cache?

If you are facing connectivity issues or are suspicious of DNS cache poisoning, you can perform DNS flush. A DNS flush, as the name suggests, refers to resetting or clearing the cache.

Flushing the cache removes all entries which include any invalid or poisoned entries. After a flush, the DNS cache gets repopulated using records from the configured DNS server the next time you access those websites.

In addition to your computer, your router may have a DNS cache as well. If flushing the DNS cache on your computer doesn’t solve the connectivity issue, troubleshoot the router by rebooting it.

As domain name server cache is a temporary memory, rebooting the router removes all entries including the ones that are corrupted.

Commands to flush DNS cache

Windows 10

Clearing DNS cache on a Windows 10 system is very simple and takes two steps.

Step 1: Hold down the Windows key and press ‘R’. This will bring up the Run dialog box.

Step 2: In the dialog box, type the following: ‘ipconfig /flushdns’. Click on ‘Ok’ button or hit Enter.

You will notice that a command box will flash on for a split second and the DNS cache would be cleared.

Windows 8

Follow the steps below to clear domain name server cache on Windows 8 system.

Step 1: Open the WinX menu by pressing Win and X key together.

Step 2: Right-click on command prompt and launch it as an administrator.

Step 3: Type the following on the command prompt: ‘ipconfig /flushdns’ and press Enter.

If DNS cache is flushed successfully, you will get the following message on the command prompt: “Windows IP configuration successfully flushed the DNS Resolver Cache.”

Windows 7

Follow the steps below to clear domain name server cache on Windows 7 system.

Step 1: Open Start menu by clicking on the Start button.

Step 2: In the Start menu search box, type cmd to search for the command prompt.

Step 3: Right-click on command prompt and launch it as an administrator.

Step 4: Type the following on the command prompt: ‘ipconfig /flushdns’ and press Enter.

If DNS cache is flushed successfully, you will get the following message on the command prompt: “Windows IP configuration successfully flushed the DNS Resolver Cache.”

Mac OS

To clear domain name server cache on your Mac OS, follow the given steps:

Step 1: Launch Terminal. You can do this by going to Applications -> Utilities -> Terminal.

Step 2: The command to flush DNS cache vary from version to version in MAC OS. Choose the appropriate command for your OS version and enter it on your terminal.

Mac OS X versions 10.10.4 and newer:

“dscacheutil -flushcache; sudo killall -HUP mDNSResponder”

Mac OS X versions 10.10-10.10.3:

“sudo discoveryutil mdnsflushcache; sudo discoveryutil udnsflushcaches”

Mac OS X versions 10.9:

“sudo killall -HUP mDNSResponder”

Mac OS X versions 10.6-10.8:

“sudo dscacheutil -flushcache”


Many versions of Linux do not employ a local DNS cache. Check the website for your Linux distribution to see if it supports local DNS resolving. You also need to check for the default DNS caching software for your distribution.


One of the commonly used DNS caching application in Linux is Name Service Caching Daemon (NSCD). To clear cache for NSCD, use of the following commands:

– Clear DNS cache for the current user:

“nscd -i hosts”

– Clear DNS cache for all users:

“Nscd -I hosts”

In some Ubuntu versions, you can clear the domain name server cache by using the following command:

“sudo service dns-clean restart”

Note – You might need administrative privileges for this and also you will be prompted for the password.


You May Also Like

SAN (Storage Area Network) – Definition and Details

SAN, also known as the System Area Network, is a high-speed network that connects and allows shared pools of block-level storage to be accessed by dedicated or multiple servers.

Introduction to Client-Server Networks

The client-server network is a computer networking model where at least one of the computers (called server) is used to “serve” other computers (called clients). Examples of some of servers include mail server, file server, and web server.

What is Virtual LAN (VLAN)? – A Beginner’s Guide

A virtual local area network, abbreviated as VLAN, is a collection of devices that are grouped together from different physical LANs and are configured in a way as if they are attached to the same wire.

What is Dynamic IP Address? Static vs Dynamic

A dynamic IP address is a temporary Internet Protocol (IP) address which is allotted to a computing system and can change with time. Dynamic IP addresses are usually implemented by ISPs and networks having a large number of connecting clients or end-nodes.

Satellite Internet – A Good Option for Rural Areas

The satellite internet is a high-speed internet connection provided through the communication satellites. It is location independent and offers global coverage.

More Articles Like This