Guides
- Hosts file change not taking effect on Mac
Why an /etc/hosts edit on macOS seems to do nothing: the DNS cache, the browser's own cache, a VPN's split-DNS resolver, the order of lines, and how to check which one it is.
- Edit the hosts file on macOS
How to open and edit /etc/hosts on a Mac with sudo, what the format is, how to add IPv6 lines, and how to undo a change cleanly.
- Flush the DNS cache on macOS (14, 15, and 26)
The command that flushes the DNS cache on every current macOS version, what each half does, when a flush is actually needed, and what it does not fix.
- What /etc/resolver is on macOS and who put files there
The /etc/resolver directory sends lookups for one domain to a specific DNS server. Tools like dnsmasq setups, Docker helpers, and VPN clients leave files there; here is how to read, test, and remove them.
- VPN is connected but internal hostnames do not resolve on Mac
How macOS decides which DNS server answers for a corporate domain over VPN (scoped resolvers and supplemental match domains), how to see that decision with scutil, and the three usual reasons it goes wrong.
- Reading scutil --dns on macOS
A field-by-field walk through scutil --dns output: resolver blocks, nameserver, search domain, domain, if_index, flags, reach, and order, and what the "DNS configuration (for scoped queries)" section means.
- ping, dig, and the browser give different IPs on Mac
Why three tools on the same Mac can resolve one hostname three ways: ping and curl use the system resolver with the hosts file, dig talks to a DNS server directly, and browsers may cache or use their own resolver.
- Wildcard in the hosts file on Mac: *.example.test in /etc/hosts
/etc/hosts has no wildcards on macOS: *.myapp.test is read as a literal name. List each hostname, or use dnsmasq with an /etc/resolver file.
- Block a website on Mac using the hosts file
Add 0.0.0.0 example.com and 0.0.0.0 www.example.com to /etc/hosts with sudo, flush the DNS cache, and restart the browser. Plus why it sometimes does nothing.
- localhost resolves to ::1 or is slow on Mac
localhost on a Mac is ::1 first, then 127.0.0.1. Why a dev server works at one and refuses at the other, what Node 17 and Node 20 changed, and how to see which address is listening.
- Switch hosts files between dev, staging, and prod on Mac
Commented blocks, separate files copied into place, and a marked-block script: how each switches /etc/hosts, how each goes wrong, and how to check which setup is live.
- Restore the default hosts file on Mac
What the stock macOS /etc/hosts contains, how to put it back from Apple's own copy with one command, the root:wheel 644 permissions, and the DNS flush afterwards.
- /etc/hosts permission denied or read-only on Mac
"Permission denied", vim's "E45: 'readonly' option is set", and "Operation not permitted" when saving /etc/hosts: sudo, sudo -e, tee, lock flags, and managed Macs.
- Preview a website on its new server before changing DNS (Mac)
Point the domain at the new server's IP in /etc/hosts, prove you reached it with dscacheutil and curl, deal with HTTPS and IPv6, or use curl --resolve and Chrome's --host-resolver-rules instead.
- Chrome ignores the hosts file on Mac
curl follows the /etc/hosts override but Chrome does not: Chrome's host cache, kept-alive sockets, HSTS and cached redirects, a proxy resolving the name for you, and what Secure DNS does and does not do.
- Can the hosts file map a port? (Mac)
No. A hosts line with a port in it is ignored. Put the port in the URL, redirect 80 to 8080 with pf, run an nginx reverse proxy, or use curl --resolve and Chrome's --host-resolver-rules for one session.
Something missing? Email [email protected] with the error you hit.