Recently my son started to spend more time on Facebook. How much ever I tell him, he still uses it whenever I wasn’t at home. So I desperately wanted a quick trick to block Facebook on Windows (better if I can do it without installing a software) and here’s how it’s done. All you need to do is, just add few lines to your hosts File.
Advantage of Blocking websites using Hosts file
1. Easy to Use and Practical: No need to install any new software, as it might add to the system load and no need to mess with your firewall rules as well.
2. Blocking on all browser: This trick works uniformly across all the browsers in the system.
3. Blocking various websites: Besides Facebook and Twitter, you can block other websites too.
What is a Hosts file?
The hosts file is used to map hostnames to IP addresses. You can locate the file at : C:\Windows\System32\drivers\etc\hosts on your Windows OS.
Block Facebook and Twitter
Step 1: To access the hosts file, you need Administrator privileges. So open the notepad in Administrator mode.
Step 2: Now open the hosts file by navigating to the location as shown in the below image.
Step 3: Add the below lines to hosts file and save it.
127.0.0.1 www.facebook.com 127.0.0.1 facebook.com 127.0.0.1 twitter.com 127.0.0.1 www.twitter.com ::1 www.facebook.com ::1 facebook.com ::1 twitter.com ::1 www.twitter.com
Note: This trick might not work for websites that are served via HTTPs and IPv6 protocol, so you need to map Facebook to IPv6’s localhost notation as well.
Step 4: After adding entries to hosts file, you have to execute the below command as well.
Open your command line with Administrator privilege as shown in the below image.
Execute the below command:
Step 5: Now try accessing Facebook in any of your browser to only to see the message “Unable to connect”
When the browser is requested to open a website, the system firstly check the site’s IP Address defined in the hosts file. If not available, then it takes help from the DNS.
Apparently in our case, the IP address of Facebook is 127.0.0.1 or commonly called the localhost. It means that the system will not load Facebook from its original IP address, rather just show a blank page with “Unable to connect” in Firefox, whereas “Internet Access is blocked” in Google Chrome browser.
The above trick can also be used in other operating systems like MAC and any flavors of Linux too.
Comments Leave a Comment
Not bad, but hardly an exhaustive list. Remember, these sites use various domains to spy on you. I’ll research more and report back. And yes, twenty years ago I was using HOSTS to block noxious sites at my cyber cafe. Now that I’m sitting at home criticizing everyone else, I thought I’d stop MyFace from harvesting my web browsing habits. I’ll find the Twaster bugs as well… good luck.