Locahl
cheat sheetDNShosts filemkcertreference

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).

L

Locahl Team

·2 min read

One-page reference for local development DNS and hosts — copy, print, or bookmark.

Flush DNS cache

OSCommand
macOS (Sequoia/Tahoe+)sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder
Windows 11ipconfig /flushdns (admin)
Windows PowerShellClear-DnsClientCache
Linux (systemd)sudo resolvectl flush-caches
Ubuntu/Debiansudo systemd-resolve --flush-caches

Deep dives: Mac · Tahoe · Sequoia · Windows · Linux

Hosts file paths

OSPathAdmin required
macOS / Linux/etc/hostsYes (sudo)
WindowsC:\Windows\System32\drivers\etc\hostsYes

Guides: Mac · Windows 10 & 11 · Win11 24H2 · Linux

Hosts file syntax

TEXT
127.0.0.1    myproject.test
127.0.0.1    api.myproject.test
::1          myproject.test
203.0.113.50 staging.example.com

Rules: IP first, then hostname(s), no https://, no ports. See syntax guide.

mkcert HTTPS local (Mac)

BASH
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

BrowserURL / action
Chromechrome://net-internals/#dns → Clear host cache
Firefoxabout:networking#dns → Clear DNS Cache
SafariDevelop → Empty Caches
Edgeedge://net-internals/#dns

Chrome on Mac guide

Verify DNS resolution

BASH
# 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 +short

Common fixes

SymptomFix
Hosts change ignoredFlush system DNS + browser cache
Access denied saving hostsRun editor as administrator
NET::ERR_CERT_AUTHORITY_INVALIDmkcert -install, regenerate cert → [[mkcert-net-err-cert-authority-invalid-mac
ERR_NAME_NOT_RESOLVED[[err-name-not-resolved-mac
Wrong IP after migrationRemove 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*

Also readComplete cross-platform hosts guide
Share this article
Available on Windows, macOS & Linux

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
Buy Locahl, €4.99One-time payment, no subscription

Related Articles

4 min read
hosts filetroubleshootingDNS

/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.

L

Locahl Team

Developer tools team

2 min read
localhost127.0.0.1DNS

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.

L

Locahl Team

Developer tools team

3 min read
DNSChrometroubleshooting

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.

L

Locahl Team

Developer tools team

3 min read
DNSMicrosoft Edgecache

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.

L

Locahl Team

Developer tools team