To flush the DNS cache on a modern Mac, open Terminal and run two commands together: sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder. The first clears the directory-service cache, the second restarts the resolver that handles name lookups. This fixes sites that resolve to an old or wrong IP address after a DNS change, and it takes effect immediately.

TL;DR

  • Flush DNS: sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder.
  • This fixes "site loads the old server" issues after DNS or hosts changes - it does not free disk space.
  • App caches live in ~/Library/Caches; most are safe to clear and apps rebuild them.
  • Quit an app before deleting its cache folder to avoid corrupting an open file.
  • Leave /System and system-managed caches alone; macOS owns those.

How do I flush the DNS cache?

Open Terminal (Applications > Utilities > Terminal) and run:

sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder

Enter your admin password when prompted - it will not echo as you type. Both commands run silently and return you to the prompt with no output, which is normal. You flush DNS when a domain you control was just repointed, when a site stubbornly loads from an old IP, or after editing /etc/hosts. It does not reclaim storage; DNS records are tiny.

How do I clear application caches?

User-level app caches sit at:

~/Library/Caches

Each app keeps a subfolder here, often named in reverse-domain style like com.apple.Safari. To inspect it, open Finder, press Shift-Cmd-G, and paste the path. You can safely delete the contents of individual subfolders - apps regenerate what they need on next launch. The safest practice is to quit the app first, then remove that one folder, rather than wiping the whole Caches directory while apps are running.

Which caches are safe, and which are not?

Safe to clear: browser caches, media-thumbnail caches, and most third-party app caches under ~/Library/Caches. Riskier: deleting a cache for an app that is mid-write can leave it confused until relaunch, so quit first. Off-limits: /Library/Caches at the system root and anything under /System - those are managed by macOS, and there is a separate, protected /System/Volumes/Data kernel and dynamic-loader cache you should never touch manually.

What does macOS do natively, and where does it stop?

macOS rotates and prunes many caches on its own, and the Storage tools (System Settings > General > Storage) can remove some user data. But macOS deliberately does not expose a "flush DNS" button - that is Terminal-only by design. It also will not let you selectively clear a single misbehaving app's cache; the native tools think in broad categories. So for DNS and for targeted cache clearing, the commands and Finder path above go where the GUI stops.

What this cannot do, and what to leave alone

Flushing DNS will not fix a genuinely down website, a bad Wi-Fi connection, or a VPN routing problem - it only clears locally cached lookups. Clearing ~/Library/Caches will not noticeably speed up a healthy Mac; caches exist to make apps faster, so a wipe just forces a one-time rebuild. Never rm -rf the entire ~/Library folder - it holds your Mail, Messages, app preferences, and Keychain. To find what is genuinely large before deleting anything, a size-first scan beats guessing, much like using TreeSize on Windows.

FAQ

Do I need to restart my Mac after flushing DNS?

No. The killall -HUP mDNSResponder command restarts the resolver immediately, so the flush takes effect the moment the command completes. A full reboot also clears the DNS cache but is unnecessary for this purpose.

Is it safe to delete everything in ~/Library/Caches?

Clearing individual app subfolders is safe, since apps rebuild their caches. Wiping the entire folder at once is technically recoverable but riskier if apps are running, so quit your apps first and prefer deleting per-app folders over a blanket wipe.

Why is there no output after running the flush commands?

That is expected. Both dscacheutil -flushcache and killall -HUP mDNSResponder complete silently and return you to the prompt. No message means success; an error would print text. You can confirm by reloading the site that was misbehaving.

On your phone, Cleanor handles this kind of cleanup automatically - see Cleanor for iPhone.