Guide

How to flush the DNS cache on a Mac

Websites not loading after a DNS change? The Terminal command to flush the DNS cache on macOS Sonoma, Sequoia and later, and when to use it.

Updated 3 min read

Your Mac remembers which IP address each website name points to, so it doesn't have to ask every time. When those addresses change, for example after a website moves to a new server or you edit DNS records or your hosts file, the old answers can stick around and sites won't load. Flushing the DNS cache fixes that.

The command

Open Terminal (in Applications → Utilities) and run this on macOS Sonoma, Sequoia and later:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

Enter your Mac password when asked. Nothing is shown while you type it, which is normal. The command prints nothing when it succeeds.

When to flush DNS

  • A website loads on your phone but not on your Mac.
  • You changed a domain's DNS records and want to see the change now.
  • You edited /etc/hosts and the change doesn't take effect.
  • You switched VPN, DNS server or network and some sites still go to the old place.

Clear your browser's cache too

Some browsers keep their own short-lived DNS cache. In Chrome, Edge and other Chromium browsers, go to chrome://net-internals/#dns and click Clear host cache. Restarting the browser clears it as well.

Still not working?

  • Check that the problem isn't the website: try another network or a phone on mobile data.
  • Check your DNS servers in System Settings → Network → your connection → Details → DNS.
  • Restart your router, which keeps its own DNS cache.

Flush DNS in one click with Roomy

Roomy's Optimize screen has a Flush DNS cache task that runs the same command for you. macOS asks for your administrator password; Roomy never sees it.

Frequently asked questions

Is it safe to flush the DNS cache on a Mac?

Yes. The DNS cache only remembers which address each website name pointed to. Flushing it makes your Mac look the addresses up again; nothing else changes, and the first visit to each site may take a fraction of a second longer.

Do I need to restart after flushing DNS?

No. The change is immediate. If a site still loads the old address, also clear the browser's own host cache or restart the browser.

How often should I flush DNS?

Only when you need to, for example after changing a domain's DNS records, editing the hosts file, switching VPN or network settings, or when a site loads on other devices but not on your Mac.

Give your Mac room to breathe.
Start with a free scan.

Download Roomy, see exactly what is taking up space, and clean up to 500 MB for free. Nothing is removed until you say so.

Version 1.0.0 5 MB macOS 14 Sonoma or later Apple silicon and Intel