How to Flush DNS Cache in macOS Using Terminal

When migrating websites, reconfiguring nameservers, or diagnosing network reachability issues on a Mac, you may discover that your browser continues pointing to an obsolete IP address. This occurs because macOS caches Domain Name System (DNS) query responses locally in memory to accelerate everyday browsing and minimise upstream server lookups.

While local DNS caching improves connection speed, it can prevent your Mac from recognising updated DNS records, new CDN endpoints, or modified local hosts entries. By issuing native cache-invalidation commands in macOS Terminal, you can purge stale DNS entries instantly and force the system to perform fresh upstream lookups.


How DNS Caching Works in macOS

In macOS (including modern versions such as macOS Sequoia and macOS Sonoma), local DNS resolution is managed primarily by two daemon architectures:

  • Directory Service Cache (dscacheutil): The framework that maintains active directory lookups, user identities, and resolved hostnames across native applications.
  • multicast DNS Daemon (mDNSResponder): The core background daemon responsible for unicast DNS lookups and Bonjour service discovery. When an address changes, restarting this daemon forces an immediate reload of resolver configurations.

How to Flush the DNS Cache in Modern macOS

The standard command to flush the DNS cache combines both the Directory Service cache purge and the mDNSResponder reload. This syntax applies to macOS Sequoia (macOS 15), macOS Sonoma (macOS 14), macOS Ventura (macOS 13), and macOS Monterey (macOS 12).

  1. Open Terminal on your Mac (press Command + Space, type Terminal, and press Enter).
  2. Copy and paste the following compound command:
    sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
  3. Press Enter.
  4. Type your Mac user administrator password when prompted (characters will not appear on the screen as you type) and press Enter.

When executed successfully, Terminal will return to a clean prompt without printing an error message. macOS immediately flushes its internal cache table and terminates the stale responder instance.


Adding Audible or Visual Confirmation to the Command

Because the standard command completes silently, you can append a terminal notification or vocal alert using macOS’s native say command to verify that the operation finished:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder; say "DNS cache flushed"

Alternatively, print a clean text confirmation directly inside your terminal window:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder; echo "macOS DNS Cache Successfully Cleared."

DNS Cache Commands Across Older macOS Versions

If you are maintaining legacy Mac workstations running older releases of OS X or macOS, the syntax differs slightly:

macOS Version Required Terminal Command
macOS Monterey through Sequoia (12.0+) sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
macOS Big Sur and Catalina (10.15 – 11.0) sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder
macOS High Sierra and Mojave (10.13 – 10.14) sudo killall -HUP mDNSResponder
macOS Sierra (10.12) sudo killall -HUP mDNSResponder
OS X Yosemite (10.10.4+) sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

Troubleshooting Persistent DNS Resolution Issues

If web pages continue resolving to stale servers even after executing the flush command, evaluate the following browser-level and network caches:

  • Browser Host Cache: Web browsers like Google Chrome maintain their own internal DNS socket pools. Navigate to chrome://net-internals/#dns and click Clear host cache.
  • Safari Domain Cache: If Safari refuses to load an updated domain, you may need to clear HSTS and website data for specific domains in Safari Settings.
  • Router and ISP DNS: Local routers frequently store DNS caches for hours. Restart your local gateway or configure public resolvers such as Cloudflare (1.1.1.1) or Google DNS (8.8.8.8) in your Mac’s Network Settings.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.