Hosts File Editor
Edit your hosts file in a form. Add, remove, and switch entries on or off, get warnings for invalid addresses, wildcards, and duplicate hostnames, and download the result or restore the Windows, macOS, or Linux default.
Input
Output
Readme
What is a hosts file?
The hosts file is a plain text file that maps hostnames to IP addresses on your own computer. Your system checks it before asking a DNS server, so a line in it overrides what DNS would answer. Developers use it to point a domain such as myapp.test at their own machine or a staging server, and people use it to block sites by sending them to 0.0.0.0. Each line holds one IP address followed by one or more hostnames, and anything after a # is a comment.
| System | Location |
|---|---|
| Windows | C:\Windows\System32\drivers\etc\hosts |
| macOS | /etc/hosts (also /private/etc/hosts) |
| Linux, BSD | /etc/hosts |
| Android (root) | /system/etc/hosts |
Tool description
This tool lets you edit a hosts file in a form. Paste your hosts file and each entry appears as a card with its IP address, hostnames, and comment. Switch an entry off and it is commented out with #, switch it on again and the # goes away. Add, change, or remove entries, and the text is rewritten right away. Comments, blank lines, and the spacing of lines you didn't touch are kept as they were. When you are done, copy the text or download it as a file named hosts. Everything happens in your browser, and your hosts file is not sent anywhere.
If your hosts file is broken, pick Windows, macOS, or Linux under "Default hosts file" to start again from the file that system ships with. The Linux file uses my-computer as the computer name, so replace it with yours.
Features
- Finds entries that were commented out and shows them as switched off, so you can turn them back on with one click.
- Warns about invalid IP addresses, entries without a hostname, and hostnames that are not valid.
- Explains common mistakes: a URL such as
https://example.com/instead ofexample.com, a port, a wildcard such as*.example.com(hosts files don't support them), a name with non-ASCII letters that has to be written in Punycode, and an IP address and hostname in the wrong order. - Warns when a hostname is already mapped earlier in the file. Systems use the first match, so the later mapping is ignored. IPv4 and IPv6 are checked apart, since mapping a name to both
127.0.0.1and::1is normal. - Filters entries by IP address, hostname, or comment, which helps with long blocklists.
- Lines up the hostnames in one column with the align button under the text.
Examples
Start with this hosts file:
127.0.0.1 localhost
# 127.0.0.1 myapp.testSwitch on the second entry, add the hostname api.myapp.test to it, and add an entry that blocks ads.example.com. The text becomes:
127.0.0.1 localhost
127.0.0.1 myapp.test api.myapp.test
0.0.0.0 ads.example.comTips
Saving the hosts file needs administrator rights. On Windows, open Notepad as an administrator and paste the text into the file. On macOS and Linux, run sudo nano /etc/hosts.
Your system and browser may keep old answers for a while. To see the change right away, clear the DNS cache:
- Windows:
ipconfig /flushdns - macOS:
sudo dscacheutil -flushcache; sudo killall -HUP mDNSResponder - Linux with systemd-resolved:
resolvectl flush-caches
A browser that goes through a proxy lets the proxy look up names, so the hosts file on your computer has no effect there.