When a system DNS works for a long time, it saves many records that cause DNS works slowly or not working correctly. To flush DNS cache, you need to clear DNS records from your system. You can do it with the command line in command prompt and Windows Powershell and Terminal on macOS systems.
The flush DNS command is the tool you need to clear and flush DNS cache. Just open the command line interface and dump the correct DNS cache then remove it.
The Domain Name System (DNS) is a hierarchical decentralized naming system for computers, services, or other resources connected to the Internet or a private network. It associates various information with domain names assigned to each of the participating entities. Most prominently, it translates more readily memorized domain names to the numerical IP addresses needed for locating and identifying computer services and devices with the underlying network protocols.
Clear and Flush DNS Cache with the command line:
- Open a command-line interface
- Display DNS Records
- Flush DNS Cache
- Check DNS Records
To flush DNS cache just follow the step by step guide. It works the same on all Windows operating systems, but different on various macOS and Linux distributions.
Related: Install and Configure DNS Server on Windows Server.
How to View DNS Cache
To view DNS cache on Windows systems, just type “ipconfig /displaydns” in command prompt.
- Press Windows+R to open the Run.
- Type “cmd” and press enter to open the command prompt.
- Now type “ipconfig /displaydns” to view DNS cache and records.
The ipconfig /displaydns result is like this.
C:\>ipconfig /displaydns Windows IP Configuration 569-vt.c3tag.com ---------------------------------------- Record Name . . . . . : 569-vt.c3tag.com Record Type . . . . . : 1 Time To Live . . . . : 2150 Data Length . . . . . : 4 Section . . . . . . . : Answer A (Host) Record . . . : 67.220.103.115 Record Name . . . . . : 569-vt.c3tag.com Record Type . . . . . : 1 Time To Live . . . . : 2150 Data Length . . . . . : 4 Section . . . . . . . : Answer A (Host) Record . . . : 66.180.64.115 sc.iasds01.com ---------------------------------------- Record Name . . . . . : sc.iasds01.com Record Type . . . . . : 5 Time To Live . . . . : 660 Data Length . . . . . : 8 Section . . . . . . . : Answer CNAME Record . . . . : anycast.sc.iasds01.com Record Name . . . . . : anycast.sc.iasds01.com Record Type . . . . . : 1 Time To Live . . . . : 660 Data Length . . . . . : 4 Section . . . . . . . : Answer A (Host) Record . . . : 199.166.0.200 i1.wp.com ---------------------------------------- Record Name . . . . . : i1.wp.com Record Type . . . . . : 1 Time To Live . . . . : 4175 Data Length . . . . . : 4 Section . . . . . . . : Answer A (Host) Record . . . : 192.0.77.2 usw12.lunrac.com ---------------------------------------- Record Name . . . . . : usw12.lunrac.com Record Type . . . . . : 1 Time To Live . . . . : 351 Data Length . . . . . : 4 Section . . . . . . . : Answer A (Host) Record . . . : 209.50.48.91 egqegkuoocwcdb ---------------------------------------- Name does not exist. staticxx.facebook.com ---------------------------------------- Record Name . . . . . : staticxx.facebook.com Record Type . . . . . : 5 Time To Live . . . . : 12 Data Length . . . . . : 8 Section . . . . . . . : Answer CNAME Record . . . . : scontent.xx.fbcdn.net Record Name . . . . . : scontent.xx.fbcdn.net Record Type . . . . . : 1 Time To Live . . . . : 12 Data Length . . . . . : 4 Section . . . . . . . : Answer A (Host) Record . . . : 31.13.86.4 lvplwmvbubf ---------------------------------------- Name does not exist. www.internetdownloadmanager.com ---------------------------------------- Record Name . . . . . : www.internetdownloadmanager.com Record Type . . . . . : 1 Time To Live . . . . : 18558 Data Length . . . . . : 4 Section . . . . . . . : Answer A (Host) Record . . . : 169.55.0.224 C:\>
There are too many DNS records on my system. But this is just an example of DNS cache in Windows system.
Flush DNS Cache in Windows 10
To clear Windows 10 DNS cache and records, type the “ipconfig /flushdns” command in command prompt or PowerShell.
PS C:\Users\Shais> ipconfig /flushdns Windows IP Configuration Successfully flushed the DNS Resolver Cache.
That’s good, the DNS cache removed successfully. This command works the same on all Windows client and Windows server machines.
Check DNS Records
Now if you check again you can not find any DNS records.
PS C:\Users\Shais> ipconfig /displaydns Windows IP Configuration Could not display the DNS Resolver Cache.
Yes, the system can not display the DNS records. Because there is no DNS record cached yet.
Flush DNS Cache on macOS
Flushing the DNS in Mac OS X is an easy process, but the steps taken will depend on which version of OS X you are running. For the different version of macOS operating system use the following command to clear and flush DNS cache.
macOS Sierra, OS X El Capitan, Mac OS X Yosemite, Mac OS X Mavericks, Mac OS X Mountain Lion, Mac OS X Mountain Lion, and Mac OS X Lion.
If you are running Mac OS X 10.11, you need to follow the below steps:
- Open up the command terminal.
- Run the command
sudo killall -HUP mDNSResponder
Mac OS X Snow Leopard.
If you are running Mac OS X 10.6, you need to follow the below steps:
- Open up a command terminal.
- Run the command
sudo dscacheutil -flushcache
Mac OS X Leopard and below.
If you are running Mac OS X 10.5.1 or below, you need to follow the below steps:
- Open a command terminal.
- Run the command
sudo lookupd -flushcache
Flush DNS Cache on Linux
If you are running the nscd Name Service Cache Daemon and wish to flush your DNS cache, then you will need to do the following.
- Open up a command terminal (either as root or run step 2 with
sudo
). - Run the command
/etc/init.d/nscd restart
- Now, you just have to restart the NSCD. To do, type the following command
sudo /etc/init.d/nscd restart
Finally, ask your question related to the DNS server from the comment section.