5 Free Tools to Block Websites by Using Hosts File
The HOSTS file is found on every operating system and is used to manually force map a hostname to an IP address without relying on a DNS service. For Windows, it is located in Windows\System32\drivers\etc\ and has no file extension. By default, the HOSTS file contains no active mappings (all lines in a default HOSTS file are comments) and most computer users wouldn’t have a need to manually touch the file.
A common usage of the HOSTS file is to block advertisements, trackers, and malicious websites by mapping a website domain to localhost which is 127.0.0.1. Using HOSTS has also become a popular way to help block the huge amounts of telemetry sent to Microsoft by Windows 10 and 11.
As an example, if you want to block the computer from accessing Facebook, simply create a new line in the HOSTS file with the following mapping:
127.0.0.1 www.facebook.com
This will make Facebook inaccessible on the computer (in the web browser and elsewhere), as you can see by watching the short video below. Do note that some websites may or may not require www in the domain name because of redirection. For example, Facebook requires www while a website like Twitter does not. If in doubt, you can use both to ensure the block works.
Below is a selection of tools that help you edit the HOSTS file along with adding and removing entries. The HOSTS file is also a good place to look if you are having issues accessing certain websites. Perhaps the website has previously been blocked in HOSTS. Administrator access is required to edit the HOSTS file although you can still view it without such privileges.
1. HostsMan
HostsMan is a multi purpose tool that can do a number of things in relation to the HOSTS file. It can edit the HOSTS file, backup/restore/import/export files, add predefined lists of entries from local or remote sources, sort and manage entries, and exclude specific addresses from being added. Sadly, HostsMan ceased development and the last update is from 2017.
The only thing that doesn’t work correctly is a few of the included HOSTS lists are no longer available (hpHosts in particular). However, they can be removed and replaced with alternatives, such as the Steven Black HOSTS lists. The editor is pretty simple to use and you can easily add, remove, enable, disable, search (including regular expressions), and edit entries. The checkboxes add a hash sign that will comment out (disable) the entry.
On launch, HostsMan won’t ask for administrator privileges but it requires them if you want to do any sort of editing of the Windows HOSTS file. Press “Run HostsMan as Administrator” in the main window to make all the editing options become available. A portable version is also available but the main Google Drive download links on the website don’t work, so use the alternative links just below (from Softpedia).
2. BlueLife Hosts Editor
Sordum is a developer that makes dozens of useful Windows utilities. Some we’ve mentioned before like DNS Jumper and Firewall App Blocker. BlueLife Hosts Editor is similar to HostsMan in some ways because it has some additional features, such as import and export lists and a backup manager to backup and restore HOSTS files.
The default editor view is a table which makes it easier to add and edit entries to the list. Enable or disable an entry by checking or unchecking the appropriate box. Add an entry by entering the Hostname first, then select the address from the drop down list (or select resolve the Hostname), and optionally add a comment. Press the plus icon to add the entry to the list and then the green check to save the changes.
The text view is more traditional and shows the entries as a normal text editor like Notepad would. The add and delete buttons do work in this mode but make sure to highlight the entire line to remove it. A useful option to get you started is an examples menu that adds block entries for Facebook, Twitter, and YouTube to the list. BlueLife Hosts Editor is portable and has separate versions for 32-bit and 64-bit systems.
Download BlueLife Hosts Editor
3. Hosts File Editor
Hosts File Editor is more along the lines of a text editing program that handles the HOSTS file a bit better than an ordinary text editor. There are a few additional functions available such as importing Host file lists, restoring the Windows default HOSTS file, auto pinging IPs, duplicating entries, archiving HOSTS files, and disabling the HOSTS file.
Adding an entry is a touch odd but works OK. Click in the IP Address column and add the address (note 0.0.0.0 is not accepted), Press Tab or click in the Hostname box to enter the hostname. Optionally add a comment as well. Then check the box next to the entry to enable it and press Save.
The “Disable Hosts File” option actually just renames HOSTS to hosts.disabled meaning you can temporarily use the computer without a working HOSTS file. Both portable and setup installer versions are available.
4. Hosts File Editor+
If you want a feature rich HOSTS editor then HOSTS File Editor+ is one of the most complete. Even though the last update of the program is from 2020, it does have a rather quirky and old school looking user interface. HOSTS File Editor+ is portable but for some obscure reason, it is archived into a RAR file so you will need an archiver such as 7-Zip or WinRAR to unpack it first.
Some of the most basic functions are pretty useful, such as reset HOSTS to default depending on OS, lock it to read only, disable it, backup/restore, and add default entries for Facebook, Twitter, Instagram, YouTube, a few porn sites, and selected third party applications/services. Editing is not actually done through the text area but the boxes on the right. Add an address and hostname to the boxes then press Add.
You can also add entries from remote lists although we found many of them no longer work. You can, however, add your own lists by supplying a URL. Another set of blocklists are for Windows 10 telemetry to stop Windows phoning home so much. A few select other features are edit proxy settings, change MAC address, only allow approved websites, TEMP cleaner, block applications, and clean Windows update history.
5. Edit the HOSTS File with Windows NotePad
Of course, the easiest way to edit the Windows HOSTS file would be using the simple built-in text editor, Notepad. As you don’t need any fancy editing functions, Notepad will do the job fine. More advanced editors like those above or NotePad++ will work even better for searching, replacing entries, importing lists, etc.
The issue with Notepad is it needs to be run as administrator to edit HOSTS. You can’t just simply type Notepad into Start or the search box and press Enter. One option is to type Notepad into search, hold Ctrl+Shift and press Enter. This brings up the UAC prompt to run Notepad as administrator. Obviously, administrators that don’t run UAC won’t have this issue and can freely edit HOSTS.
Another easy option is creating a desktop shortcut that opens HOSTS directly for editing in Notepad with administrative privileges.
1. Right click on the Desktop > New > Shortcut. In the item location box that pops up, enter the following:
Notepad C:\Windows\System32\drivers\etc\HOSTS
Note that Windows will fill in the full path to Notepad for you.
2. Click Next and give the shortcut a name, such as “Edit HOSTS”. Click Finish.
You now have a shortcut that when double clicked will open HOSTS in Notepad. But it still won’t save after editing because anything being saved in System32 requires elevated privileges for security reasons. One extra step is required.
3. Right click on the new shortcut and select Properties. Press the Advanced button in the Shortcut tab and check the “Run as administrator” box. Press OK.
From now on, Notepad will open as administrator and automatically open HOSTS when you launch it from the shortcut and you will be able to edit and save changes without error. For ease of use, you can download a ready made shortcut below.
Download Administrator Notepad HOSTS Editor shortcut
Final Note: Having an updated HOSTS file is useful to block unnecessary websites but a huge HOSTS file could be problematic. Some users on the internet report an increased startup time booting into Windows and applications that use the Internet when starting up. We have never noticed any major issues or slowdowns but if you do have similar issues, try reducing the number of entries in the HOSTS file.
It’s also worth bearing in mind that some antivirus software monitors the HOSTS file for unauthorized changes. You may be blocked from editing or deleting/replacing HOSTS unless the option is disabled in the software.
Would ask that you consider adding our lists to your article. Thank you!
github.com/blocklistproject/Lists
The problem is:
Many standard AV programs now block access to the Hosts file.
This makes it nigh impossible to know for sure that the Hosts file is responsible.
It also makes it difficult to add or remove entries.
I can’t see why these obvious irritations persist in 2017.
I now have a number of reasonably safe sites (including “My PayPal”) that I can’t access. The cure is worse than the disease!
Which AV are you thinking of in particular?
Some of the ones I’ve tried in recent months might warn or ask you about editing HOSTS, but they certainly don’t block access to it.
There are good tools to boot a USB stick that will allow editing the host file in windows that bypass it’s security unless you’ve foolishly let those third parties encrypt your drive.
You boot them and they’ll give you a GUI interface but it’s core is linux. Probably Ultimate Boot CD will work for you but read up on it.
Been a long user of HOSTS. Imagine my surprise when it seems to have been easily circumvented by a new Chrome extension I added (ZenMate). I double- and triple-checked… the website being blocked was definitely on my HOSTS list, it’s blocked when ZenMate is disabled/removed from Chrome. It”s unblocked when it’s enabled… Any ideas on how it does this?
Cheers!
Any program can do this. Even the Tor Browser does it. Windows 10’s Telemetry does it too. The solution is to not use this software. You can also install a solution like uBlock Origin or similar if you want to keep using ZenMate. https://www.raymond.cc/blog/10-ad-blocking-extensions-tested-for-best-performance/
You can however not expect much from a free VPN (see Hola VPN scandals). The VPN servers cost money (bandwidth, electricity) and if the service is being offered for free you can imagine what they pay the bills with. If you are interested in getting a paid VPN look here: privacytools.io/#vpn
Also here: reddit.com/r/Android/comments/43bgxr/ive_seen_some_people_ask_about_vpns_recently_and/
This works great for blocking websights for your children, but when they wise up to it? Hm…is there a way to hide the etc file and put a dummy one in its place?
Make your child a standard user account and create an admin account with a password. Only admins can edit the hosts file.
I use “HostsMan” to manage my HOSTS file. It let’s me backup, optimize and also can download custom hosts files (like MVPS) from different sources. Really, the best
HOSTS files are superb! at blocking specific websites, domains and even specific pages on specific sites. They can be used to protect you from visiting infected sites, drive-by malware locations, etc. They can also be used to block specific ads and third=party content that slow down browsing.
I just added some sites that have been loading with my email program and slowed down my pc and can not believe how fast my PC got after I blocked them!
Raymond.cc is always help us by giving so may tips like this.
I also have turned into a fanatic of Raymond.cc
A nice stuff.
Nice one Raymond, your blog is the best.
I’d never stop reading you.
It’s a wise thing you’ve done by putting raymond.cc on all pictures, those copy cats will definitely find another source.
let me digg this thing!
That definitely should work with the kids, but not with us.
Love your blog, a fan from early 2006 and you actually inspired me with the straight forward tweaks.