Sponsored

Not the solution you were looking for?

We’ll help you out!

How to block access to Facebook and Twitter on your Windows PC using hosts file

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.

Open Notepad with Administrator Privilege

Step 2: Now open the hosts file by navigating to the location as shown in the below image.

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:

ipconfig /flushdns

Step 5: Now try accessing Facebook in any of your browser to only to see the message “Unable to connect”

Explanation:

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.