How to clear the local DNS cache in Linux?

Nowadays many Linux distributions do not utilize a local DNS resolver cache, like Windows and Mac OS X. If you do not know whether your distribution has such local DNS caching, we would recommend you to check the official website of your Linux installation.

Here is how to flush the DNS cache in Linux:

  • Open your Terminal.
  • Restart the name service cache daemon by executing this command:

sudo /etc/init.d/nscd restart

There are some cases when the nscd daemon might not be installed. In Ubuntu (and other Debian-based distros) you can install it from your Terminal by executing this command:

sudo apt-get install nscd

For any RedHad-based distributions (such as Fedora, CentOS) you can install the nscd daemon through the yumpackage manager:

yum install nscd

It is advisable to clear up your browser’s cache as well.