Where Is the macOS Hosts File?
macOS /etc/hosts path, editing rules and DNS cache flushing.
Last updated
macOS resolves custom domains through /etc/hosts before DNS, with one mapping per line and System Integrity rules around editors. Ad-block and dev-redirect workflows share this single file.
Edit with sudo and flush caches after every change since lookups linger. Line-ending mistakes silently void entries below them.
Where macOS stores this, by platform
/etc/hosts
Symlinked hosts file with IPv4 and IPv6 loopback defaults. Edit as admin, keep one mapping per line, then flush with dscacheutil -flushcache plus mDNSResponder restarts. Back up before blocklist pastes.
Frequently asked questions
Why do hosts changes not apply?
DNS caches above ignore edits until flushed. Restart browsers too since they cache resolutions separately.
Can hosts block ads on macOS?
Yes for known domains through the file above. Browsers with secure DNS may bypass it unless disabled.
Notice an outdated path? Let us know.