How to Flush DNS cache on Linux

Last updated by Sam K on July 23, 2021 12:11

Linux systems don’t have a DNS cache by default. The different distributions only offer a function to store DNS information locally with the use of appropriate applications like nscd (name service caching daemon), pdnsd, dns-clean, or dnsmasq. If you use one of these services for caching, you have to control it from the terminal in order to clear the cache.

For pdnsd, there’s a concrete clear command:

sudo pdnsd-ctl empty-cache

To clear the DNS cache from dnsmasq, dns-clean, or ncsd, though, you need to completely restart the respective service:

sudo /etc/init.d/dnsmasq restart

sudo /etc/init.d/nscd restart

sudo /etc/init.d/dns-clean restart

To use DNS caching services in Linux distributions like Ubuntu and clear the cache, you need administrator rights.

VPNSecure Provides Secure VPN servers in over 45+ Countries

If you are a looking for a versatile easy to use VPN service, checkout Today