DNS & Hosts File Cheat Sheet (Mac, Windows, Linux)
Printable cheat sheet: flush DNS commands, hosts file paths, mkcert setup, and browser cache clears for macOS, Windows 11, and Linux (2026).
Locahl Team
Table of Contents
One-page reference for local development DNS and hosts — copy, print, or bookmark.
Flush DNS cache
| OS | Command |
|---|---|
| macOS (Sequoia/Tahoe+) | sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder |
| Windows 11 | ipconfig /flushdns (admin) |
| Windows PowerShell | Clear-DnsClientCache |
| Linux (systemd) | sudo resolvectl flush-caches |
| Ubuntu/Debian | sudo systemd-resolve --flush-caches |
Deep dives: Mac · Tahoe · Sequoia · Windows · Linux
Hosts file paths
| OS | Path | Admin required |
|---|---|---|
| macOS / Linux | /etc/hosts | Yes (sudo) |
| Windows | C:\Windows\System32\drivers\etc\hosts | Yes |
Guides: Mac · Windows 10 & 11 · Win11 24H2 · Linux
Hosts file syntax
127.0.0.1 myproject.test
127.0.0.1 api.myproject.test
::1 myproject.test
203.0.113.50 staging.example.comRules: IP first, then hostname(s), no https://, no ports. See syntax guide.
mkcert HTTPS local (Mac)
brew install mkcert && mkcert -install
mkcert localhost 127.0.0.1 ::1 myproject.test "*.myproject.test"Framework wiring: mkcert setup · Vite & Next.js
Clear browser DNS
| Browser | URL / action |
|---|---|
| Chrome | chrome://net-internals/#dns → Clear host cache |
| Firefox | about:networking#dns → Clear DNS Cache |
| Safari | Develop → Empty Caches |
| Edge | edge://net-internals/#dns |
Verify DNS resolution
# macOS
dscacheutil -q host -a name myproject.test
ping -c 1 myproject.test
# Windows
ping myproject.test
nslookup myproject.test
# Linux
getent hosts myproject.test
dig myproject.test +shortCommon fixes
| Symptom | Fix |
|---|---|
| Hosts change ignored | Flush system DNS + browser cache |
| Access denied saving hosts | Run editor as administrator |
| NET::ERR_CERT_AUTHORITY_INVALID | mkcert -install, regenerate cert → [[mkcert-net-err-cert-authority-invalid-mac |
| ERR_NAME_NOT_RESOLVED | [[err-name-not-resolved-mac |
| Wrong IP after migration | Remove old hosts entry, flush DNS |
Locahl workflow
1. Edit hosts visually (multi-environment profiles) 2. One-click DNS flush built in 3. Export/import JSON for the team
---
*Last updated July 2026. Share this page with your team — link: locahl.app/en/blog/dns-hosts-cheatsheet*
Ready to simplify your workflow?
Stop wasting time with the terminal. Locahl lets you manage your hosts file in a few clicks, with automatic validation and no risk of errors.
- Intuitive visual interface
- Automatic DNS flush
- Multi-environment management
- Automatic backups
- JSON Import/Export
Related Articles
/etc/hosts Not Working? Fixes for Windows, Mac & Linux
The hosts file is ignored or /etc/hosts changes do not take effect? Fix it on Windows, Mac and Linux: flush DNS, check syntax, IPv6, line endings, resolver caches and save permissions.
Locahl Team
Developer tools team
127.0.0.1 vs localhost: What’s the Difference?
127.0.0.1 vs localhost explained: both point to your machine, but they differ in DNS resolution, IPv6, and hosts file behavior. When to use each, with examples.
Locahl Team
Developer tools team
Fix DNS_PROBE_FINISHED_NXDOMAIN (2026)
Fix DNS_PROBE_FINISHED_NXDOMAIN in Chrome and Edge: flush DNS, check the hosts file, reset DNS servers and clear the browser cache. Step-by-step solutions.
Locahl Team
Developer tools team
Clear DNS Cache in Microsoft Edge (2026)
Clear the DNS cache in Microsoft Edge with edge://net-internals/#dns, flush socket pools, and clear the Windows DNS cache so hosts changes take effect.
Locahl Team
Developer tools team
Which TLD to Use for Local Development (.test vs .localhost)
Which TLD to use for local development: prefer .test, avoid .dev and .local. Why .test is reserved, how to map it in the hosts file, and HTTPS tips.
Locahl Team
Developer tools team