How To Flush Local DNS Cache on Linux

How To Flush Local DNS Cache on Linux

Most latest distributions are running either “systemd-resolve” or “nscd“. Probably, that you might be working with “dnsmasq” or “BIND“. In any case, flushing the DNS cache is generally easily as restarting whichever daemon is running.


Ubuntu and other Debian-based distributions are possibly running systemd-resolve. If everything is already set up on Ubuntu, just ready to go and flush your cache by telling systemd to clear it.

sudo systemd-resolve ––flush-caches

NSCD (Name Service Cache Daemon)

If you’re running the RedHat-based distributions (CentOs 7) and Arch Linux, there’s a good chance it’s using nscd. You only have to restart the service to flush out the DNS cache.

sudo systemctl restart nscd


dnsmasq is another choice. Dnsmasq is more considerable for local DNS servers and its regularly used on routers. You need to restart the service like with nscd.

sudo systemctl restart dnsmasq


At last, BIND is also standard choice. It’s not a lot of distributions it by default, however you certainly may experience it. BIND is still utilised for purpose-built DNS servers.

sudo systemctl restart named

You shouldn’t have any issue to flush your DNS cache whenever DNS service your computer is running. Restarting most DNS servers is a simple fix. For Debian-based distributions, you can use a built-in function in systemd to flush your DNS cache. In all cases, the procedure is quite easy and it doesn’t require a restart of your entire system.