There are myriad reasons why you may not want certain websites to be accessible from your browser. Maybe you don’t want kids in your house accessing naughty content, or perhaps you want to block those “fake news” sites that are making all the headlines these days.
Or maybe you just don’t want to instinctively keep clicking on Facebook or YouTube every five minutes when you should be working? No need to explain. Here’s our guide on how to block websites using the host file in Windows 10. No need for third-party extensions or anything like that – just good old-fashioned host file tweaking.
Say Hello to the Hosts File
If you’ve done tweaking to your Windows 10 Internet settings before, then you may be familiar with the hosts file. Despite being a very simple file, it plays an important part in managing your computer’s communication with the Internet. Specifically, it lets you override the Domain Name System (DNS) which assigns domain names/websites to specific IP addresses and connects you to them.
In layman’s terms it lets you decide which websites you want your PC communicating with and how you want it communicating with them. So using the hosts file you can block sites, redirect them, and other fun little tricks. For today, however, we’ll just focus on the blocking.
Block Websites Using Your Hosts File
All this may sound kind of complicated, but it really isn’t.
First, navigate to the System32 directory of Windows, which by default should be “C:\Windows\System32\Drivers\etc\.”
Create a backup of your hosts file in case you do something wrong. (I’m sure you won’t!) Simply right-click the hosts file, click “Copy,” then find a place where you want to keep the backup and paste it there.
Once you’ve done that, back in the “etc” folder right-click the file called “hosts,” click Open With, then select Notepad.
You’ll now see your hosts file splayed out in Notepad format. You should see several entries with the numbers 127.0.0.1. These are loopback protocols which basically translates to “Your Computer.” Any website you assign with this IP address will look for that website on your computer, and fail to do so because that website of course isn’t stored on your computer. This way the website is effectively blocked.
So to block a website (or many websites), all you need to do is start a new line at the bottom of the Notepad document and type
127.0.0.1 www.facebook.com or whatever the name of the site you want to block is.
For each new site you want to block, start a new line and go through the same procedure. When you’re done, just click “File,” then “Save,” and those pesky websites you don’t want in your life will no longer be accessible from any of your browsers. If you decide you miss those sites and want them back, just open the hosts file in Notepad again and delete the specific entries for the sites you want back. (Be careful about what you delete, and whatever you do, DON’T delete the hosts file itself!)
I’ve always believed that if there’s a way to do something internally in Windows, you should do that instead of using third-party apps. If, however, you’re not entirely comfortable with this, then there are good extensions for each individual browser that will do the job. Check out our list of extensions for blocking websites in Chrome to get an idea. Firefox has a good one called LeechBlock, and there are plenty of others out there.
With that said, I don’t feel the need to use those when I have my humble hosts file right here.