How to Block Websites By Editing the HOSTS File in Windows

How to Block Websites By Editing the HOSTS File in Windows

DNS, short for Domain Name System, converts IPv4 or IPv6 addresses to names and then back to IP addresses. For instance, when you visit a website, DNS reveals the true IP address to your web browser, which in turn fetches the web page directly from that IP address.

As expected, translating IP addresses to website names takes time, potentially causing access delays. If DNS servers go down, accessing websites through their URLs becomes impossible. This situation is not uncommon.

It is necessary to create a hostname-to-IP address mapping list, which is the purpose of the Windows HOSTS file. On Windows systems, the content of the HOSTS file takes priority over other methods like DNS.

The Windows HOSTS file can be used to improve website access speed, test websites locally, and block specific websites across all browsers. Blocking websites through the HOSTS file is an effective method.

This article provides tips on managing the HOSTS file and blocking websites using it. There are two methods discussed:

1. Manual editing of the HOSTS file.

How to use the HostsMan editor tool efficiently

1. Edit HOSTS File Manually

Windows NT platform systems, such as Windows 2000, Windows XP, and Windows 7, have their HOSTS file in the path %SystemRoot%\system32\drivers\etc\ (“%SystemRoot%” is a relative path, typically C:\Windows or C:\WINNT).

To access the HOSTS file, simply type the path mentioned above in the Windows search bar or run box, which will take you to the “etc” folder where the file can be found.

See also  Canva vs Adobe Spark: Which Design Web App Is Better?

Any text editor can be used to open and edit the file.

How to Block Websites By Editing the HOSTS File in Windows

Note: For Windows 7 users, there’s one more step. Type “Notepad” in the Start Menu search bar, then right-click on the “Notepad” item and choose “Run as administrator”. Now you can open the HOSTS file using the “File -> Open” menu in Notepad.

How to Block Websites By Editing the HOSTS File in Windows

The HOSTS file contains lines of text with an IP address and one or more hostnames. You can add the mapping relationship for each website. Comment lines are indicated by a hash (#) character and are ignored by the system.

How to Block Websites By Editing the HOSTS File in Windows

To block a website, add this line: 127.0.0.1 facebook.com

2. Edit HOSTS File with HostsMan Editor

HostsMan Editor is a sleek interface for managing your HOSTS file. If you use your HOSTS file frequently, I recommend using this tool.

How to Block Websites By Editing the HOSTS File in Windows

As shown in the screenshot above, the add button allows you to block sites. Simply map them to the localhost IP.

You can add, delete, or temporarily disable items using this tool. It can also list potential risk items in the “Possible Hijacks” section.

That’s how you can use the HOSTS file in Windows to block websites.

Also, check our review of OpenDNS, an alternative method to filter accessed websites on your computer.

Leave a Comment