How to Flush DNS Cache in Sun Solaris

It may be sometime required to flush your DNS Cache mostly when trying to troubleshoot a problem with your name service or when there was an invalid DNS entry after a server outage. The possible solution to clear these cached invalid entries or to wait till the record expires based on its TTL (Time To Live)

The NSCD daemon in Solaris and ofcourse in UNIX and most of the Linux falvors maintains the system cache including the DNS/Name service cache.

All it needs is to restart the nscd aemon to flush the DNS cache.

Do a

# ps -ef|grep nscd

This will find the PID for the NSCD daemon.

Now, do a

#pkill <PID>

#kill <PID>

Now, check if the nscd process is killed by using

# ps -ef|grep nscd

Now, start the nscd daemon by using

#/usr/sbin/nscd

 This should start the nscd daemon and there you go, you have flushed the DNS Cache in your Solaris Server.

Click here for the man page for NSCD in Solaris

5 thoughts on “How to Flush DNS Cache in Sun Solaris”

  1. Just to bring this question and answer up to date. With Solaris 11, the correct method is:

    svcadm restart /system/name-service/cache

    This will handle stopping and starting the name service cache daemon, which can be viewed by the following, noting that the PID of nscd changed.

    # ps -ef | grep nscd | grep -v grep
    root 27004 25753 0 Mar 05 ? 19:59 /usr/sbin/nscd
    # svcadm restart /system/name-service/cache
    # ps -ef | grep nscd | grep -v grep
    root 10668 25753 0 13:59:49 ? 0:01 /usr/sbin/nscd

Leave a Comment

Your email address will not be published.