folder-openclocksearcharrow-rightarrow-leftmail4facebook2twittergithublinkedin

Block Facebook with a hosts file


The hosts file is a computer file used in an operating system to map hostnames to IP addresses. The hosts file is a plain-text file and is conventionally named hosts. (This file has no file name extension, it’s simply called hosts).

You can use a hosts file to block ads, banners, malware or specific websites like in this guide. This is accomplished by blocking the connection to these websites or files (specifically by redirecting any connection attempts back to the local (your) machine.)

Location of the hosts file

This guide will assume you are on a Windows OS. The easiest ways to locate the hosts file is to open the Run dialog (Windows button + R) or simply use the search box in Windows 7.

Type %SystemRoot%\system32\drivers\etc\ and press enter

Windows Run dialog

Editing the hosts file

You will now be in the folder containing the hosts file.

hosts file folder on a Windows 7 machine

Before you continue, make a backup of the hosts file by first selecting it, copying (CTRL + C) and pasting (CTRL + V) it in the same folder.

Now we want to edit it. Right click it and select Open, select Notepad and press OK.

hosts file

We are now editing the hosts file. Find the part where it looks like the following:

127.0.0.1       localhost

and add this:

127.0.0.1 www.facebook.com
127.0.0.1 facebook.com

It should look like this now:

127.0.0.1       localhost
127.0.0.1       www.facebook.com
127.0.0.1       facebook.com

Finishing up

Save the file and exit. Facebook is now blocked, enjoy your new found productivity!

2 responses to “Block Facebook with a hosts file

Post a comment


*