Skip to content

How to block websites using the Hosts file


The hosts file can block websites or redirect websites.  For Windows users:

Step 1 – Open Notepad – “Run as ADMIN”

You can’t save the hosts file, unless you have Admin rights…

Start >  All Programs

Accessories > Notepad

Right Click Notpad  > Run as Administrator


run as admin****

File Open

All Files **Bottom left of dialogue box**


Note how it defaults to .txt (bottom right hand corner), we need to change this to ALL FILES.

etc defaults to txtALL FILES

all filesThat’s the only tricky bit.


Step 2 – Locate your Hosts file

Computer > C: Drive

Windows > System32 > drivers > etc >hosts


hosts directory

Hosts file will open

hosts blank

Yay…. Here comes the fun bit.


Step 3 – How to block Google using the hosts file – with a www address.

Beware.. wordpress are making this a http:// address – all you need is the www website name.🙂




block google 127


Step 4 – Test the hosts file blocks

Close down your web browser and reopen it.

1. Try to go to – it should generate an error “Unable to connect”

test google

How does this happen? is a special IP – it’s a “virtual” or fake IP on your own laptop.

Therefore you’re redirecting into the ether of a virtual – or fake IP.   Woohoo!!


Step 5 – Hard code in IP numbers to site – to speed dial into websites

Just in case the DNS system ever fails (ie how to find websites), you can put the IP and website directly into the hosts file.  If the DNS system fails – you can still access the sites hardcoded into your computer.  Only you will be able to… and I’ve experienced the DNS servers at a telephone exchange failing… and I was the only person with Internet access for 2 weeks.  So you’ll never know when this will be handy for you.

It makes your system DNS server fault tolerant.

It makes your web browsing of these sites much faster.


Step 6 – How do I find out the IP address of a web site?

Start > All Programs

Accessories > CMD Prompt

Type in “ping” or “ping”

ping startpageWe can see from the reply that the IP for Startpage is

So in the hosts file enter:

hosts startpage added******

Step 7 – Temporarily block a site by using the hash symbol in the hosts file

You might want to block a site now and again… not permanently.

Place a hash # in front of the line in your hosts file – and it will be ignored.  So….


will NOT work – as it’s got the hash at the start of the line.  Remove the Hash and it then blocks Google.  It’s like a little light switch turning the blocking on and off.

This can be used to block the DNS of your ISP for a short while.


Now have some fun.

Add in all your favourite websites.  Providing they have a static IP, you can now “speed dial” them an this will improve the speed of your browsing and your fault tolerance to DNS failures.

Did you get an error message?

If you see this – you haven’t opened Notepad with Admin rights.

hosts error

It won’t allow  you to save your hosts file.


What FREE DNS servers can I use on Windows 7?

  1. Also useful if the root DNS servers get tampered with, for whatever reason.


    • Hiya!
      Yeah, I have speed dials to favourite web sites set up in the hosts files….
      If the government wants to block access, they’ll mess up the DNS system. So having static IP numbers hand coded into the DNS means you can bypass this restriction.🙂
      Love it🙂


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: