How To Block Websites By Editing Hosts File In Windows 7/Vista/XP


There are several ways for blocking access to websites, such as installing a Parental Control software or using the built-in Windows 7 Parental Controls, or a Firefox plug-in. Another method for blocking websites is to edit the hosts file on your system, and add all the unwanted websites. The hosts file is a system file that is used to map hostnames to IP addresses, without any DNS resolution.

Let us assume you want to completely block facebook.com, twitter.com, and orkut.com.

Editing Hosts File In Windows XP

Open the Hosts file located at C:\WINDOWS\system32\drivers\etc folder using Notepad and add the following line at the end

127.0.0.1       facebook.com twitter.com orkut.com

In case your hosts file already has localhost as one of the entries, add the blocked websites after this.

127.0.0.1       localhost facebook.com twitter.com orkut.com

Editing Hosts File In Windows 7 And Windows Vista

In Widows 7 as well as Vista, you get a ‘Access denied’ error when you try to save the Hosts file in Notepad. A work around for this issue is given by Microsoft. The trick is to open Notepad using the ‘Run as administrator’ option. For doing this, search for ‘Notepad’ in the Start Menu search box. Right click on Notepad and then select ‘Run as administrator’.

Type your admin password when prompted by the UAC and click ‘Allow’ or ‘Yes’ for confirmation.

block_websites_edit_hosts_file

Then edit the Hosts file by adding this line at the end:

127.0.0.1       facebook.com twitter.com orkut.com

In case your PC is also a webserver and your hosts file already contains localhost as one of the entries, add the blocked websites after this.

127.0.0.1       localhost facebook.com twitter.com orkut.com

Hosts File On Other OS

On Mac OSX and iPhone, you will find the Hosts file in the location /private/etc/hosts or /etc/hosts.

Android: /system/etc/hosts

Windows Mobile: Registry key under \HKEY_LOCAL_MACHINE\Comm\Tcpip\Hosts

That’s it. Your kids will no longer be able to access the social networking sites from any browser. All they get is a ‘Server not found’ error.