How to Flush the Local DNS Cache in Linux Server

If your system has difficulty reaching an explicit web site or server this could be due to a corrupt local DNS cache.

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

Step 1: For Using the command line open your terminal

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

user@host:~$ su 
Password: (type your root user password here)
root@host:

Step 3: After that you have to restart the name service cache daemon (NSCD):

root@host: /etc/init.d/nscd restart

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

If you’ve got NSCD installed, you can clear the local DNS cache by running one among the subsequent commands in your favorite terminal/shell application. To clear local DNS cache for this user:

nscd -i hosts

To clear local DNS cache for all users use below command:

nscd -I hosts

Note: The name service cache daemon (NSCD) won’t be installed by default on your Linux. You need to be ready to install it by using the package manager of your distribution – yum for RedHat-based distribution like Fedora, CentOS and apt-get for Debian-based distribution like Ubuntu, Kubuntu.