Share your love
How To Clear DNS Cache in Linux

In this tutorial on the Orcacore website, you will learn to Flush or Clear DNS Cache in Linux. A DNS cache (sometimes called a DNS resolver cache) is a temporary database, maintained by a computer’s operating system, that contains records of all the recent visits and attempted visits to websites and other internet domains.
In other words, a DNS cache is just a memory of recent DNS lookups that your computer can quickly refer to when it’s trying to figure out how to load a website.
When troubleshooting cache poisoning or other internet connectivity problems, a computer administrator may wish to flush (i.e. clear, reset, or erase) a DNS cache.
Since clearing the DNS cache removes all the entries, it deletes any invalid records too, and forces your computer to repopulate those addresses the next time you try accessing those websites. These new addresses are taken from the DNS server your network is set up to use.
Table of Contents
Steps To Clear DNS Cache in Linux
To complete this guide, you must log in to your Linux server as a non-root user with sudo privileges. Now follow the steps below.
Flush DNS Cache with systemd-resolved in Linux
The easiest way to flush the DNS on Linux, if you are using systemd-resolved, is to use the “systemd-resolve” command followed by “–flush-caches”.
Alternatively, you can use the “resolvectl” command followed by the “flush-caches” option.
# sudo systemd-resolve --flush-caches
# sudo resolvectl flush-caches
To confirm that you have to enter the following command:
sudo system-resolve --statistics
If you see that the “current cache size” is zero, you will get confirmation that your DNS cache has been cleared.
Conclusion
At this point, you have learned to Clear DNS Cache in Linux. Clearing the DNS cache in Linux removes outdated or incorrect DNS records, ensuring accurate domain resolution and fixing connectivity issues.
Hope you enjoy it. Please subscribe to us on Facebook, YouTube, and Instagram.
Also, you may like these articles:
Check Installed Linux Kernel in Command Line