How Effective is Blocking Websites using HOSTS file?
A HOSTS file is used to manually force map a hostname to an IP address without relying on a DNS service. The HOSTS file is found on every operating system and for Windows, it is located at Windows\System32\drivers\etc\ folder, just with the filename as HOSTS without an extension. By default the HOSTS file doesn’t contain any mappings and most computer users don’t even need to touch the file. The below image is how the default Windows HOSTS file looks like.
However, web developers who are developing websites locally from their computer may find it useful because they can download the whole website’s code to their computer, map the domain name to their computer’s IP address and immediately start editing without worrying about the absolute URLs. Another common usage of HOSTS file is to block websites including advertisements and web trackings by mapping it to a localhost which is 127.0.0.1 or to a non-routable 0.0.0.0 IP address. Other than using the HOSTS file for good purposes, some malware uses it to block the infected computers from accessing security based websites.
There are times when you need to check the HOSTS file, for example when you suddenly find a website inaccessible from a particular computer while it loads perfectly fine on others. Here is how to view and edit the HOSTS file in Windows.
The easiest way to open the HOSTS file using Notepad is by typing the command at the Search programs and files bar and simultaneously press Ctrl+Shift+ENTER followed by clicking the Yes button. Do note that if you do not run notepad under administrator privileges, you will only get to view the HOSTS file and unable to save the changes.notepad %windir%\system32\drivers\etc\hosts
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
Do take note that blocking just facebook.com using the HOSTS file does not block www.facebook.com. Depending on the website, Facebook automatically redirects the non-WWW version to the WWW, while Twitter does the opposite by redirecting the WWW to the non-WWW version of the domain name. You can see the video demo on the effectiveness in blocking Facebook using the HOSTS file in Windows 7.
Because of the effectiveness in using the HOSTS file to block out unwanted websites, some anti spyware program such as Spybot immunizes your system by adding more than 15,000 entries to your HOSTS file. The Spybot immunization database is quite old and was last updated more than a year ago. The better alternatives that we recommend are HOSTS file maintained by MVPS with over 16,000 entries and hpHosts with over 180,000 entries.
To install the HOSTS file by MVPS, download the ZIP file, extract, right click at mvps.bat file and select Run as administrator. As for hpHosts, it is much easier because it comes with an installer that can even automatically disable the Windows DNS Client service by checking an option.
We have previously mentioned that malware also uses this method to prevent you from accessing certain websites that can potentially help to remove the malware by either redirecting you to another website or simply block the website. One way to determine if the blocked website you’re trying to access is listed in the HOSTS file is by using the PING command. First you need to ping the blocked website from your computer using command prompt.
1. Press the WIN key on your keyboard, type cmd and press ENTER.
2. Type ping www.facebook.com (you can replace the www.facebook.com with the address that you want to test) and press Enter. Take note of the resolved IP address that I have circled in yellow.
3. Then go to Pingdom Tools, enter the website in the box and click the Test Now button. Take note of the IP address and compare it with the one that you got from your computer. If both of the IP addresses are different, or listed as 127.0.0.1 or 0.0.0.0 from your computer, then it is very likely that the website is blocked using the HOSTS file.
Fortunately resetting the HOSTS file to default is really easy. You can either open the HOSTS file with Notepad as shown earlier, deleting everything inside and save it, or you can just download, run the Fix it 50267 tool created by Microsoft and follow the on-screen instructions.
Final Note: Having an updated HOSTS file is really useful to block unnecessary websites such as advertisements, trackers, parasites and etc but huge HOSTS file can be problematic. First of all you may notice performance degradation where it takes longer to boot in to Windows and also any application that uses the Internet also seems to hang for a while during startup. The bigger problem would be your Internet connection stops working and the only way to fix the problem is to disable the DNS Client service. When the DNS Client service is disabled, the HOSTS file will be read repeatedly whenever an application makes a DNS lookup.
Would ask that you consider adding our lists to your article. Thank you!
github.com/blocklistproject/Lists
The problem is:
Many standard AV programs now block access to the Hosts file.
This makes it nigh impossible to know for sure that the Hosts file is responsible.
It also makes it difficult to add or remove entries.
I can’t see why these obvious irritations persist in 2017.
I now have a number of reasonably safe sites (including “My PayPal”) that I can’t access. The cure is worse than the disease!
Which AV are you thinking of in particular?
Some of the ones I’ve tried in recent months might warn or ask you about editing HOSTS, but they certainly don’t block access to it.
There are good tools to boot a USB stick that will allow editing the host file in windows that bypass it’s security unless you’ve foolishly let those third parties encrypt your drive.
You boot them and they’ll give you a GUI interface but it’s core is linux. Probably Ultimate Boot CD will work for you but read up on it.
Been a long user of HOSTS. Imagine my surprise when it seems to have been easily circumvented by a new Chrome extension I added (ZenMate). I double- and triple-checked… the website being blocked was definitely on my HOSTS list, it’s blocked when ZenMate is disabled/removed from Chrome. It”s unblocked when it’s enabled… Any ideas on how it does this?
Cheers!
Any program can do this. Even the Tor Browser does it. Windows 10’s Telemetry does it too. The solution is to not use this software. You can also install a solution like uBlock Origin or similar if you want to keep using ZenMate. https://www.raymond.cc/blog/10-ad-blocking-extensions-tested-for-best-performance/
You can however not expect much from a free VPN (see Hola VPN scandals). The VPN servers cost money (bandwidth, electricity) and if the service is being offered for free you can imagine what they pay the bills with. If you are interested in getting a paid VPN look here: privacytools.io/#vpn
Also here: reddit.com/r/Android/comments/43bgxr/ive_seen_some_people_ask_about_vpns_recently_and/
This works great for blocking websights for your children, but when they wise up to it? Hm…is there a way to hide the etc file and put a dummy one in its place?
Make your child a standard user account and create an admin account with a password. Only admins can edit the hosts file.
I use “HostsMan” to manage my HOSTS file. It let’s me backup, optimize and also can download custom hosts files (like MVPS) from different sources. Really, the best
HOSTS files are superb! at blocking specific websites, domains and even specific pages on specific sites. They can be used to protect you from visiting infected sites, drive-by malware locations, etc. They can also be used to block specific ads and third=party content that slow down browsing.
I just added some sites that have been loading with my email program and slowed down my pc and can not believe how fast my PC got after I blocked them!
Raymond.cc is always help us by giving so may tips like this.
I also have turned into a fanatic of Raymond.cc
A nice stuff.
Nice one Raymond, your blog is the best.
I’d never stop reading you.
It’s a wise thing you’ve done by putting raymond.cc on all pictures, those copy cats will definitely find another source.
let me digg this thing!
That definitely should work with the kids, but not with us.
Love your blog, a fan from early 2006 and you actually inspired me with the straight forward tweaks.