PDA

View Full Version : HOSTS file not working



stevesumner
23-03-2010, 05:57 PM
Hi there,

I am trying to use the HOSTS file to block some sites but to no avail. This is on Windows XP SP3
I have:


The correct file - %SystemRoot%\System32\drivers\etc\hosts
Have not done something silly like giving the file an extension
Followed the advice on this forum: http://www.bleepingcomputer.com/tutorials/tutorial52.html, and rebooted
Disabled the DNS client service (and rebooted)
Entries are like this:
127.0.0.1 http://site.com
127.0.0.1 http://www.site.com (e.g. have two entries for the same site, one with http://www and one with just http://


Can anyone help me?

Pancake
23-03-2010, 06:08 PM
Download the program HostsXpert (http://www.funkytoad.com/download/HostsXpert.zip)

Unzip HostsXpert.zip
It will create a folder named HostsXpert in whatever folder you extract it to.
Run HostsXpert.exe by double clicking on it.
Click the Make Writeable? button.
Click Restore Microsoft's Hosts File and then click OK.
Click the X to exit the program

Note: If your Hosts file no longer exists, you will get a warning similar to "HOSTS file does not exist, Press OK to create HOSTS file". Please select Ok if that is the case.
If you have added modifications to your hosts file, they will need to be re-added

==============================

Now, we are going to replace it with a clean one.

Download this:
http://www.mvps.org/winhelp2002/hosts.zip

Unzip (Extract) the download ...
Highlight, right-click on the included HOSTS file and select: Copy

Navigate to:
C:\windows\system32\drivers\etc\

Right-click and select: Paste

fred_fish
23-03-2010, 06:27 PM
Hi there,

Entries are like this:
127.0.0.1 http://site.com
127.0.0.1 http://www.site.com

Can anyone help me?
Should be like this:

0.0.0.0 site.com
0.0.0.0 www.site.com

Speedy Gonzales
23-03-2010, 06:30 PM
Umm no, 127.0.0.1 should work. Why are you disabling the service?

fred_fish
23-03-2010, 06:43 PM
Umm, yes.
127.0.0.1 should work as well, as long as your pc is not answering on the requested port.
It may also cause a delay while it times out waiting for a response, depending on OS.
I find 0.0.0.0 works more reliably and with no delay.
But the protocol prefix (http://) is not part of the name resolution process and should definitely be omitted from the domain name.

MushHead
23-03-2010, 08:30 PM
Lose the "http://" in front of your entries. The hosts file just deals in raw domain names.

stevesumner
24-03-2010, 09:45 AM
I have tried all the suggestions and nothing worked. Disabled the DNS client cos some other forums suggested it, I have re-enabled it now. Tried 0.0.0.0 site.com and 0.0.0.0 www.site.com, still can navigate to those sites no problems.

Speedy Gonzales
24-03-2010, 10:43 AM
Dont put the www either just the site and put 127.0.0.1 instead of 0.0.0.0

SolMiester
24-03-2010, 11:07 AM
Hi there,

I am trying to use the HOSTS file to block some sites but to no avail. This is on Windows XP SP3
I have:


The correct file - %SystemRoot%\System32\drivers\etc\hosts
Have not done something silly like giving the file an extension
Followed the advice on this forum: http://www.bleepingcomputer.com/tutorials/tutorial52.html, and rebooted
Disabled the DNS client service (and rebooted)
Entries are like this:
127.0.0.1 http://site.com
127.0.0.1 http://www.site.com (e.g. have two entries for the same site, one with http://www and one with just http://


Can anyone help me?

I would suggest using a DNS service where you create your own account and have the web sites blocked you wish.

fred_fish
24-03-2010, 11:20 AM
I have tried all the suggestions and nothing worked. Disabled the DNS client cos some other forums suggested it, I have re-enabled it now. Tried 0.0.0.0 site.com and 0.0.0.0 www.site.com, still can navigate to those sites no problems.

You need to flush your DNS cache or it will just use the last cached lookup

ipconfig /flushdns

Terry Porritt
24-03-2010, 01:32 PM
Make sure your HOSTS file has the entry:- 127.0.0.1 localhost

Also make sure you have also flushed your browser cache/history as well as dns cache

bevy121
24-03-2010, 01:55 PM
what are you using to edit the host file?

If notepad etc, make sure it's not being saved as host.txt

You are probably aware of this, but I'll say it just in case :)

(The .txt extension is not seen unless you have "Hide extensions for known filetypes" unchecked in Folder Options/View.)

When you save the file after editing - use the "Save As" and not the "Save"

Change the "Save as type" drop-down from "Text Documents" to "All Files"

make sure the file name to save as has nothing but the word "hosts" in it and click save

reboot

shaider
25-03-2010, 01:20 PM
do u use a proxy server?
I have the same issue. I just wondering maybe it's because of the proxy server. any thoughts thanks a lot

stevesumner
26-03-2010, 12:26 PM
I do use a proxy server, but I am able to surf with it turned off, using Microsoft Firewall Client. I had wondered about that myself, and I will need to test using my laptop at home using my home network, no proxy server and no firewall client etc. and see what happens. But I figured that changing the NS lookup order via the regedit to set the hosts file as the first lookup should have meant that the name was resolved to localhost straight away, thereby effectively blocking access to the site.

stevesumner
26-03-2010, 01:09 PM
Right, problem solved! It is the proxy server and the reason I didn't figure this out earlier was that I hadn't flushed my browser cache as well as dns cache like Terry suggested. I think I was doing one or the other, but never both.

Thanks to you all for your help.

Cheers.

Steve (not the real stevesumner)