How to Clear the DNS Cache on macOS (Terminal Commands)
When a website refuses to load correctly after you change hosting providers, edit a domain record, or move a site to a new server, the culprit is often a stale DNS cache sitting on your Mac. Your computer keeps a local copy of recent DNS lookups to speed up browsing, and sometimes that copy points to an address that no longer exists. The fix is to clear the DNS cache on macOS using two short Terminal commands.
This guide walks through exactly which commands to run, why modern macOS requires both of them together, how the commands changed across macOS versions, and when flushing actually helps.
Key Takeaways
• On modern macOS, clear the DNS cache by running `sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder` together in Terminal.
• Running only one of the two commands often leaves cached entries behind — you need both.
• You must use `sudo` and enter an administrator password because DNS caching is a system-level service.
• Flush the cache after DNS or hosting changes, when a site moves servers, or after editing `/etc/hosts`.
• Browsers like Chrome keep their own separate DNS cache that the system flush does not touch.
What is the DNS cache on macOS?
The Domain Name System (DNS) translates human-friendly domain names into the IP addresses that computers actually use to connect. Every time you visit a site, your Mac performs a DNS lookup and then stores the result locally so it does not have to repeat the request for every page.
On macOS, this local resolver cache is managed by two cooperating components:
- `dscacheutil` — the Directory Service cache utility, which handles the general system lookup cache.
- `mDNSResponder` — the background daemon responsible for unicast DNS resolution and Multicast DNS (Bonjour).
Because both components hold cached results, clearing the cache reliably means signalling both of them. This is the single most common reason a “flush” appears not to work.
Why and when should you flush the DNS cache?
Cached DNS entries are governed by a value called TTL (Time To Live) — the number of seconds a record is considered valid before it should be looked up again. Until that TTL expires, your Mac happily keeps using the old answer. Flushing the cache forces an immediate, fresh lookup instead of waiting for propagation to run its course.
You should clear the DNS cache on macOS when:
- You just changed DNS records (A, CNAME, MX, or nameserver records) and want to see the new destination immediately.
- A website moved to a new server or you switched hosting providers and the site loads incorrectly or shows an old page.
- You are troubleshooting connectivity issues, “server not found” errors, or a domain that resolves to the wrong place.
- You edited the local `/etc/hosts` file and want macOS to honor the new mapping.
- You changed your network’s DNS resolver (for example, switching to a public resolver) and want stale entries gone.
In each case, the goal is the same: remove stale entries so the next request reflects current, correct data.
How do you open Terminal and run the flush command?
The DNS flush is done from Terminal, the command-line application built into macOS.
Opening Terminal
- Press Command (⌘) + Space to open Spotlight.
- Type `Terminal` and press Return.
Alternatively, open Finder → Applications → Utilities → Terminal.
The modern flush command (macOS 10.12 Sierra and later)
On every current version of macOS, run both commands on a single line:
“`bash sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder “`
Press Return, then enter your administrator password when prompted. The password will not appear as you type — that is normal. There is no “success” message; a silent return to the prompt means it worked.
You can also run them as two separate commands if you prefer:
“`bash sudo dscacheutil -flushcache sudo killall -HUP mDNSResponder “`
The detail almost every tutorial gets wrong: on modern macOS you genuinely need both commands, and the order is deliberate. `dscacheutil -flushcache` empties the Directory Service cache, while `killall -HUP mDNSResponder` sends a hangup signal that forces the `mDNSResponder` daemon to drop its own in-memory cache and reload. Flushing only `dscacheutil` leaves `mDNSResponder` still serving old answers, which is why people complain that “flushing DNS didn’t fix anything.” Running just `mDNSResponder` can leave Directory Service entries behind. Run them together and you clear both layers in one pass.
Why is sudo required?
DNS caching is a system-level service shared by every app and user on the machine, not a per-user setting. Modifying it requires administrator privileges, which is why each command begins with `sudo` (superuser do). If your account is not an administrator, you will not be able to flush the system cache.
Which command does each macOS version use?
Apple has changed the flush command several times over the years. Older systems used utilities that no longer exist on modern macOS — most notably `discoveryutil`, which Apple introduced and then removed within a couple of releases. Use the row that matches your version.
| macOS version | Command to clear the DNS cache |
|---|---|
| macOS 11 Big Sur → current (Sequoia, Sonoma, Ventura, Monterey) | `sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder` |
| macOS 10.12 Sierra – 10.15 Catalina | `sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder` |
| macOS 10.11 El Capitan | `sudo killall -HUP mDNSResponder` |
| macOS 10.10.4 – 10.10.5 Yosemite | `sudo killall -HUP mDNSResponder` |
| macOS 10.10 – 10.10.3 Yosemite (early) | `sudo discoveryutil mdnsflushcache; sudo discoveryutil udnsflushcaches` |
| macOS 10.9 Mavericks | `sudo killall -HUP mDNSResponder` |
| macOS 10.7 – 10.8 Lion / Mountain Lion | `sudo killall -HUP mDNSResponder` |
| macOS 10.6 Snow Leopard and earlier | `sudo dscacheutil -flushcache` |
To check your version, click the Apple menu → About This Mac. If you are on any release from the last several years, the modern two-command line is the one to use.
Not sure which macOS you have on a phone-vs-computer setup? If you also manage DNS on mobile, see for the iOS equivalent and for the underlying concept.
What about the browser’s own DNS cache?
Clearing the system cache does not clear your browser’s cache. Modern browsers maintain their own separate DNS cache for performance, and it must be cleared independently.
In Google Chrome, you can flush the browser’s internal host cache by navigating to:
“`text chrome://net-internals/#dns “`
Click Clear host cache on that page. For a full reset, also visit `chrome://net-internals/#sockets` and choose Flush socket pools. Other browsers either expire their internal cache quickly or clear it when you fully quit and reopen the application.
If a site still loads incorrectly after flushing the system cache, the browser cache (or the TTL on the record itself) is usually the next thing to check.
How does this differ from Windows?
The concept is identical across operating systems, but the tooling differs. On Windows, you flush the resolver cache from Command Prompt or PowerShell with `ipconfig /flushdns` rather than Terminal. If you manage a mixed fleet of machines, see for the Windows-specific walkthrough. The reasons to flush — stale entries, DNS changes, propagation — are the same on every platform.
DNS-level confusion is frequently a propagation problem rather than a problem with your Mac. When you change a DNS record at your hosting provider, the new value does not appear everywhere at once — it rolls out gradually as caches around the world expire according to their TTL. Flushing your local cache only fixes *your* machine; the wider internet still needs time.
At DarazHost, DNS changes you make through our control panel are designed to propagate as quickly as your records’ TTL allows, and our DNS management tools make it straightforward to update A, CNAME, MX, and nameserver records without guesswork. If a change is not resolving the way you expect — even after you have flushed your local cache — our 24/7 support team can help confirm whether the record is correct, whether propagation is still in progress, or whether something else needs attention. Lower TTLs ahead of a planned migration, for example, can dramatically shorten the window where stale entries linger.
If you are about to move a site or repoint a domain, talk to us first so we can set sensible TTLs and walk you through the change.
Frequently asked questions
Do I really need to run both commands on macOS?
Yes, on modern macOS you should run both `sudo dscacheutil -flushcache` and `sudo killall -HUP mDNSResponder`. The first clears the Directory Service cache and the second forces the `mDNSResponder` daemon to drop its own cache. Running only one frequently leaves stale entries serving, which is why partial flushes appear to fail.
Why does the flush command not show a success message?
That is expected behavior. The macOS flush commands return silently — when the Terminal prompt reappears without an error, the cache has been cleared. The absence of output does not mean the command failed.
Why does the website still load the old version after flushing?
Two common reasons. First, your browser keeps a separate DNS cache (clear it in Chrome at `chrome://net-internals/#dns`). Second, the DNS change may still be propagating — until the record’s TTL expires across the network, some resolvers will keep returning the old address. Flushing your Mac only refreshes your machine.
Is flushing the DNS cache safe?
Yes. Flushing simply discards temporarily stored lookups; your Mac rebuilds the cache automatically on the next request. There is no risk to your data or settings. The only minor effect is that the very next few lookups take slightly longer because they cannot use the cache.
Do I need to restart my Mac after flushing?
No. The commands take effect immediately and a restart is not required. Restarting *will* also clear the cache as a side effect, but it is unnecessary when the Terminal commands do the job instantly.