How to Block a Website on Windows
Sometimes, there’s a need to restrict access to certain websites on a Windows computer, whether for security, parental control, or productivity reasons. Fortunately, Windows has a built-in solution for blocking sites using the hosts file. Here’s how to use it to block any site you need.
Step 1: Open the Hosts File
The hosts file allows you to redirect requests to specific IP addresses. To block a website, you’ll add its address to this file and redirect it to a non-existent IP.
- Navigate to the folder where the hosts file is located. Typically, the path is as follows:
C:\Windows\System32\drivers\etc
- Open the hosts file with administrative privileges. Right-click on a text editor (like Notepad), select Run as administrator, and then open the hosts file via File > Open in the editor.
Step 2: Add the Site to Block
Once the hosts file is open, you can add the site you want to block.
- Scroll to the bottom of the file and add a new line.
- Type the following, replacing
example.com
with the site you want to block:
127.0.0.1 example.com
Here, 127.0.0.1
points to your computer’s local IP, effectively blocking access to the site. To block multiple sites, add each on a new line following the same format:
127.0.0.1 example.com
127.0.0.1 anotherexample.com
Step 3: Save the Changes
- Once you’ve added the sites, save the hosts file by selecting File > Save.
- Close the text editor and restart your browser to apply the changes. The specified sites should now be blocked.
Step 4: Verify the Block
To confirm that the sites are blocked, try opening them in a browser. If everything is set up correctly, you should see an error indicating that the site is unavailable.
How to Unblock a Site
If you ever need to restore access to a blocked site, simply reopen the hosts file and remove the lines with the site addresses. Save the changes and restart your browser to regain access.