dscacheutil

Learn how to use dscacheutil to flush DNS cache and gather directory service information on macOS. Includes commands for Mavericks and older versions.

Dscacheutil

Understanding Dscacheutil

The dscacheutil command-line utility in macOS is a powerful tool for interacting with the Directory Service cache. It allows administrators and developers to gather information, check statistics, and perform essential maintenance tasks, most notably flushing the DNS cache. This is crucial for ensuring that your system is using the most up-to-date network information, especially after network configuration changes or when troubleshooting connectivity issues.

Flushing the DNS Cache

One of the primary uses of dscacheutil is to clear the DNS cache. This process forces your system to re-query DNS servers for domain name resolutions, which can resolve issues caused by stale or incorrect DNS entries.

Command for macOS Mavericks (10.9) and later:

dscacheutil -flushcache

Clearing DNS Cache for Older macOS Versions (10.7 and 10.8):

For older versions of macOS, specifically 10.7 (Lion) and 10.8 (Mountain Lion), a different approach is needed to clear the DNS cache. This involves sending a HUP signal to the mDNSResponder process.

killall -HUP mDNSResponder

Viewing DNS Resolver Statistics

Beyond cache management, dscacheutil can also provide insights into the performance and behavior of your DNS resolver. This can be helpful for diagnosing network performance problems.

Command to show DNS resolver statistics:

dscacheutil -statistics

External Resources