How to Flush Linux DNS Cache (NSCD)

Tags: , , , , , , , ,

If you notice that your linux machine is holding on to old DNS entries and you are running the nscd service there is a good chance that invalidating (flushing) the NSCD hosts database will help. This is roughly the linux equivalent to ipconfig /flushdns on windows or dscacheutil -flushcache on os x.

nscd -i hosts

From the NSCD man page:

The daemon will try to watch for changes in configuration files appropriate
for each database (e.g.  /etc/passwd for the passwd database or /etc/hosts and
/etc/resolv.conf for the hosts database), and flush the cache when these are
changed.  However, this will happen only after a short delay (unless the
inotify(7) mechanism is available and glibc 2.9 or later is available), and
this auto-detection does not cover configuration files required by nonstandard
NSS modules, if any are specified in /etc/nsswitch.conf.  In that case, you
need to run the following command after changing the configuration file of the
database so that nscd invalidates its cache:
$ nscd -i <database>

3 Responses to “How to Flush Linux DNS Cache (NSCD)”

  1. ccs Says:



  2. kktaus Says:

    Will this invalidation process cause a delay in service? If so for how long?


  3. xxx Says:

    nscd -i hosts


Join the Conversation