How to Flush the Local DNS Cache in Linux Server

If your computer has trouble reaching a certain website or server this may be due to a corrupt local DNS cache.

Below are the steps that will show you how to clear your local DNS cache (“flush” it) for Linux Server.

Step 1: Open your terminal to use the command line.

Step 2: Login as root user using the su command:

[email protected]:~$ su 
Password: (type your root user password here)
[email protected]:

Step 3: Restart the name service cache daemon (NSCD):

[email protected]: /etc/init.d/nscd restart

One of the most commonly used DNS caching Linux applications is NSCD (Name Service Caching Daemon).

If you have NSCD installed, you can clear the local DNS cache by running one of the following commands in your favorite terminal/shell application. To clear local DNS cache for the current user:

nscd -i hosts

To clear local DNS cache for all users:

nscd -I hosts

[alert] Note: The name service cache daemon (NSCD) might not be installed by default on your Linux. You must be able to install it by using the package manager of your distribution – yum for RedHat-based distribution such as Fedora, CentOS and apt-get for Debian-based distribution such as Ubuntu, Kubuntu.[/alert]

Powered by BetterDocs