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.

Windows hosts 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.

Hostsman

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.

Hostsman editor

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

Download HostsMan


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.

Bluelife hosts editor

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.

Bluelife hosts editor block social

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.

Hosts file editor

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.

Download Hosts File Editor


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.

Hosts file editor plus

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.

Hosts file editor plus hosts lists

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.

Download HOSTS File Editor+


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.

Hosts edit shortcut

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.

Edit hosts run as admin

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.

15 Comments - Write a Comment

  1. Garrett 4 years ago
  2. Peter O 8 years ago
    • HAL9000 8 years ago
    • Mr. Meval 4 years ago
  3. Evilbob 10 years ago
    • Pete 9 years ago
  4. conrad 12 years ago
    • Pete 9 years ago
  5. shamu726 12 years ago
  6. Anonymous 13 years ago
    • Ardiana 8 years ago
  7. Rajesh Wadher 17 years ago
  8. Nestor® 17 years ago
  9. Ralph 17 years ago
  10. Basel 17 years ago

Leave a Reply

Your email address will not be published. Required fields are marked *

Note: Your comment is subject to approval. Read our Terms of Use. If you are seeking additional information on this article, please contact us directly.