Block-Websites-with-Windows-Hosts-File

Some websites are flat out inappropriate for work or family while others are simply discouraged. This may include adult or malicious websites. Paid software can be used to block access to particular groups or whole domain names, providing safety and reducing unnecessary browser time.

A restriction option that won’t cost a dime, and is already built into Windows, is the hosts file. The Windows hosts file is located in the Windows System32 folder and provides easy setup for redirecting traffic to a more suitable location. Follow our steps and screenshots to configure the hosts file.

Editing Windows Hosts File

Opening the hosts file to block websites

The hosts file isn’t always cooperative when editing directly from its default location. Begin by copying this to your Desktop before editing.

Navigate to “C:\Windows\System32\drivers\etc” to right-click and copy the “hosts” file. Now paste it to your Desktop and double-click it. Because the hosts file contains no file extension, you’ll then be asked to choose what program to use for opening it. Choose an installed text editor like Notepad or Notepad++.

Open-the-hosts-file-with-Notepad

Editing the hosts file to block websites

Scrolling down to the bottom of the file will be a few examples. Notice that “#” signs are comments and have no effect on functionality.

View-the-hosts-file-in-Windows

Blocking a website:

The first line to the left, like “127.0.0.1” above, is where the redirect should end up while the right side is the source. So if you want to block Facebook.com, just enter 0.0.0.0 facebook.com. Please make sure that there is no # sign preceding it as shown in the image below.

Redirecting one website to another:

To find the IP address of the domain in question, pull open a command prompt from “Start > All Programs > Accessories > Command Prompt” and enter “ping technorms.com” to get the address of TechNorms.com.

For example, enter “199.38.112.245” to the left, in a new line, tab over to the right and enter “google.com.”

Redirect-Google-from-the-Windows-hosts-file

Now navigate to Google.com and notice the domain name for the specified IP address is now shown: TechNorms.com

Redirect-Google-to-TechNorms-from-the-Windows-hosts-file

This can be done for any URL and any IP address. Enter the combination “199.38.112.245” and “favoritewebsite” to gain access to TechNorms.com via the URL “http://favoritewebsite.” This is also evident when files like the following are used as the hosts file: http://web.aanet.com.au/wjaf/hosts.

This is a list of adverts and/or spyware domains that can be blocked by pointing their traffic to the local address of 127.0.0.1. Copy and paste the contents of this page into your hosts file to add these entries.

If the hosts file appears to be unrecognized by the installed browsers, there is a setting in the “LAN settings” window of the “Connections” tab in Internet Explorer’s options.

Open-the-Connections-tab-in-Internet-Explorers-Options

Uncheck the topmost setting of “Automatically detect settings.”

Uncheck-Automatically-detect-settings-in-Internet-Explorers-LAN-settings

The hosts file will now be used in browsers before the Internet DNS is polled. This is necessary for these changes in the hosts file to take effect.

Conclusion

While the hosts file has no graphical user interface, it can still be quite effective when restricting or redirecting web traffic. Configuring the hosts file to point to a local web server or device via HTTP is a quite common task completed in this file. So go ahead, enter all your favorite websites to the right most section of the hosts file and enter our IP to the left – you won’t ever miss our updates!