Edit, validate, and manage your system's hosts file with ease. Add DNS overrides, block websites, and map local domains — all in your browser. Includes presets, entry management, and a real‑time editor with syntax highlighting.
The hosts file is a plain-text operating system file that maps hostnames to IP addresses. It acts as a local DNS resolver, overriding the results from public DNS servers. Every modern OS — Windows, macOS, Linux, Android, iOS — uses a hosts file. Editing it gives you fine-grained control over network resolution without touching router or DNS server configurations.
127.0.0.1 localhost → resolves localhost to 127.0.0.1
0.0.0.0 ads.doubleclick.net → blocks ads.doubleclick.net
myapp.local to 127.0.0.1 to test websites without a DNS server.
0.0.0.0 or 127.0.0.1 to block ads, trackers, or distracting sites.
When an application tries to resolve a domain name (e.g., www.example.com), the operating system first checks the hosts file. If a matching entry is found, the IP address from the hosts file is used immediately, bypassing the DNS resolver cache and the configured DNS servers. This happens at the system level, affecting all applications — browsers, command-line tools, and services.
The file format is simple: each line contains an IP address followed by one or more hostnames, separated by spaces or tabs. Lines starting with # are comments and are ignored. The default location varies by OS:
C:\Windows\System32\drivers\etc\hosts
/etc/hosts
Immediate Effect & Caching: While the hosts file is read in real-time, modern operating systems employ aggressive DNS caching. To ensure your changes take effect without rebooting, you must flush the DNS cache:
ipconfig /flushdns.
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder.
sudo systemctl restart systemd-resolved or sudo resolvectl flush-caches.
sudo /etc/init.d/nscd restart.
Additionally, web browsers often maintain their own internal DNS caches. After flushing the OS cache, restart your browser or visit chrome://net-internals/#dns (for Chromium-based browsers) to clear the browser cache.
hosts file for your system.
Editing your hosts file is powerful but can be dangerous. Malware often modifies the hosts file to redirect banking or search domains to phishing sites. Always review entries carefully. Use the validation feature to catch suspicious entries. Never blindly paste hosts file content from untrusted sources.
On Windows, you may need to run your text editor as Administrator to save changes. On macOS / Linux, use sudo with your preferred editor. This tool does not directly write to your system — it generates the content for you to copy or download.
Hosts file modifications are a prime target for malware. Protecting the file's permissions is as critical as its content.
root (or wheel) and have permissions set to 644. This prevents unauthorized non‑admin processes from hijacking your DNS resolution. Use sudo chown root:root /etc/hosts && sudo chmod 644 /etc/hosts to reset permissions.
System32\drivers\etc directory is ineffective.
If your hosts file appears to be ignored, check for trailing spaces in domain names, invisible Unicode characters, or multiple entries for the same domain pointing to different IPs—the parser will flag these as warnings.
192.168.1.1) or IPv6 (e.g., ::1) format.
# and can appear on their own line or after an entry.
The tool validates IP format using regex and checks for duplicate domain mappings. Warnings are shown for lines that are suspicious but not strictly invalid (e.g., using 0.0.0.0 for blocking is common but flagged as a warning).
Changes to the hosts file take effect immediately on most systems, but DNS caching can cause delays. On Windows, run ipconfig /flushdns; on macOS, sudo dscacheutil -flushcache; on Linux, restart the systemd-resolved service or use sudo systemctl restart NetworkManager depending on your setup. This tool includes a helpful reminder in the validation output.
| Use Case | Entry | Effect |
|---|---|---|
| Local development |
127.0.0.1 myproject.local
|
Access local server via custom domain |
| Block Facebook |
0.0.0.0 www.facebook.com facebook.com
|
Prevent access to Facebook |
| Ad blocking |
0.0.0.0 ads.doubleclick.net
|
Block ad requests |
| Intranet mapping |
10.0.0.5 intranet.company.com
|
Internal company portal |
| IPv6 localhost |
::1 localhost
|
IPv6 loopback |
A full‑stack developer working on a microservices architecture uses the hosts file to route multiple services to localhost. For example, api.dev → 127.0.0.1:3000, frontend.dev → 127.0.0.1:8080, and auth.dev → 127.0.0.1:5000. This allows seamless integration testing without modifying DNS or using a service mesh. The developer uses this tool to quickly switch between staging and production mappings by toggling commented entries. Advanced Tip: To toggle between staging and production environments without deleting entries, simply comment out the inactive IPs using a # at the start of the line. For instance, # 192.168.1.10 api.staging.local disables the staging mapping instantly while preserving the configuration for later use.
::1 or 2001:db8::1 are fully supported and validated.