The command
- Open Terminal (in Applications › Utilities, or press Command-Space and type "Terminal").
- Paste this line and press Return:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder - Type your Mac login password when asked and press Return. Nothing appears on screen as you type; that's normal.
When it works, Terminal prints nothing and simply shows a new prompt. Close the window and try the website again, after restarting your browser (browsers keep their own cache; see below).
What each part does
sudoruns the command as an administrator, which is why you're asked for your password.dscacheutil -flushcacheclears the Directory Service cache, which holds recent lookups of host names, users and groups. Its manual page says it "flushes the entire cache" (man dscacheutil).;runs the second command after the first.killall -HUP mDNSRespondersends a "hang up" signal to mDNSResponder, the macOS service that answers DNS lookups for apps, which makes it drop the answers it has cached. It doesn't quit the service.
Apple's only page on this is archived: Reset the DNS cache in OS X is marked "no longer updated", and for OS X 10.10.4 and later it gives just sudo killall -HUP mDNSResponder. The two-part line above is the version DNS providers and hosting companies publish for current macOS (for example Namecheap), and it's what Apple's own tools still support: on macOS 27.0.1, dscacheutil's manual page documents -flushcache, and mDNSResponder is the service handling DNS. Apple doesn't document the combination itself.
When flushing DNS helps, and when it won't
DNS turns names like example.com into the numeric addresses your Mac connects to, and macOS keeps recent answers for a while. Flushing makes it ask again. That helps when the remembered answer is wrong:
- a website moved to a new server, and it works on your phone but not on your Mac;
- you edited
/etc/hosts, or changed DNS records for your own domain, and want the change used straight away; - you connected to or disconnected from a VPN, and internal or external names stopped resolving;
- a hotel or café Wi-Fi login page left a wrong answer behind.
It won't help with:
- slow internet. Lookups are a tiny part of loading a page, and after a flush the first visit to each site is very slightly slower, not faster;
- a site that's down for everyone, or Wi-Fi that keeps dropping;
- a DNS server that gives the wrong answer. Flushing just asks it again. Change servers instead (below).
Is it safe, and why does it need a password?
It's safe. Flushing only forgets cached answers; nothing is deleted from your files or settings, and macOS fills the cache again as you browse. There's nothing to undo.
It needs an administrator password because mDNSResponder runs as a system account (_mdnsresponder on macOS 27.0.1), and killall only signals processes that belong to you. You can see this safely: killall -s -HUP mDNSResponder is a dry run that sends nothing, and without sudo it reports "No matching processes belonging to you were found".
Check it worked
Two read-only commands show what your Mac is doing now. The first looks up a name the way macOS apps do:
dscacheutil -q host -a name example.com
It prints blocks of name: followed by ip_address: (IPv4) or ipv6_address: (IPv6). If the address now matches the one your web host or IT team expects, the flush did its job. The second shows which DNS servers your Mac is using:
scutil --dns
Look at resolver #1 and its nameserver[0] line. The manual page explains that the first resolver listed is the default; the ones after it, such as those for local, handle particular domains (man scutil). If resolver #1 isn't the server you expect, a VPN, a configuration profile or your router may be setting it.
Browsers keep their own DNS cache
If the site is still wrong in one browser after the flush, clear that browser's cache too:
- Chrome (and browsers built on it): go to
chrome://net-internals/#dnsand click Clear host cache. On the Sockets page next to it, Flush socket pools closes connections that are still open to the old address. - Firefox: go to
about:networking#dnsand click Clear DNS Cache. - Safari has no separate page for this. Quit it and open it again after flushing.
Changing DNS servers instead
If a particular DNS server keeps giving wrong or slow answers, change it. Choose Apple menu › System Settings, click Network, click your network service (such as Wi-Fi), click Details, then click DNS. Use the add (+) and remove (–) buttons under DNS Servers. The path is the same on macOS 15 Sequoia, macOS 26 Tahoe and macOS 27 (Apple, Change DNS settings on Mac). Note the existing entries first so you can put them back, and remember that settings are per network service: Wi-Fi and Ethernet each have their own.
Older macOS versions
For Macs on much older systems, Apple's archived article lists these (Apple):
| Version | Command |
|---|---|
| OS X 10.10.4 and later | sudo killall -HUP mDNSResponder |
| OS X 10.10 to 10.10.3 | sudo discoveryutil mdnsflushcache |
| OS X 10.7 to 10.9.5 | sudo killall -HUP mDNSResponder |
| Mac OS X 10.6 | sudo dscacheutil -flushcache |
How Tend helps
Tend's Maintenance page (Pro) has Clear the DNS cache, which runs the same two commands; macOS asks for your administrator password first. It sits next to the other occasional fixes, such as rebuilding the Spotlight index, so you don't need to remember the syntax. For a one-off, the Terminal command above does exactly the same job. For the other maintenance jobs worth knowing on Apple silicon, see Mac maintenance: what helps, what's myth.
Questions
How do I flush DNS on a Mac?
Open Terminal, run sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder and enter your administrator password. It prints nothing when it works. Then restart your browser, which keeps its own cache.
Is it safe to flush the DNS cache?
Yes. It only makes your Mac forget recent name lookups, so it asks the DNS server again. No files or settings change, and the cache refills as you browse.
Does flushing DNS speed up the internet?
No. It fixes wrong or outdated addresses for particular sites. The first visit to each site afterwards is very slightly slower, because the answer has to be looked up again.
Why do I need sudo to flush DNS?
The service that handles DNS on a Mac, mDNSResponder, runs as a system account, and macOS only lets you signal your own processes. sudo runs the command as an administrator, which is why Terminal asks for your password.
Related guides
Mac maintenance on Apple silicon: what helps, what's myth
The other fixes worth knowing, and the myths
Why is my Mac so slow? How to find the cause
If the whole Mac is slow, not just websites
Sources
- Apple, Reset the DNS cache in OS X (archived)
- Apple, Change DNS settings on Mac (macOS 15), (macOS 26), (macOS 27)
- macOS 27.0.1 manual pages:
man dscacheutil,man scutil,man killall - Namecheap, How to clear the local DNS cache (third party)
- Chromium source, net-internals page; Mozilla, about:networking strings
Keep the occasional fixes in one place
Tend is free to download. Pro is $1.99 a month, $12.99 a year with a 7-day free trial, or $29.99 once.