I updated some entries in the hosts file at C:\WINDOWS\System32\drivers\etc. As a test, I decided to make Google point to

# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
# For example:
#     rhino.acme.com          # source server
#     x.acme.com              # x client host       localhost
::1             localhost       google.com

This works fine on Windows Vista, but not on Widows 7. When I type google.com into my browser, it goes directly to Google's website.

I am not using a proxy server, and I think there might be some temporary DNS settings that need to be flushed, but I'm not sure.

Does anyone know how to fix this?

  • Just out of curiosity, why are you doing so ?
    – Sathyajith Bhat
    Sep 27 '09 at 16:13
  • to show that pseudo-hackers that post videos proving they hacked a website is not true always :)
    – user3864
    Sep 27 '09 at 16:57
  • this is why I did this :) martani.net/2009/09/bloginycom-is-hacked-google-too-video.html
    – user3864
    Sep 27 '09 at 23:10
  • What browser are you using, might be good to say. Goes right to my local apache2.4 here with FireFox on win 7. Jan 26 '14 at 2:40

You may have to restart Internet Explorer or Firefox, or whatever browser you are using.

Also, try going to command prompt and typing:

ipconfig /flushdns

Lastly, double check you are typing google.com in the address bar and remember that both google.com and www.google.com are completely different as far as DNS is concerned and you will need to add an entry for both.

  • 2
    very common misconception about the www. I've see SO many sites forget to set domain.com to forward to their web server leaving ONLY www.domain.com working or visa versa. :)
    – Jeff F.
    Jan 14 '11 at 15:35

An addition to @wil's answer.

the spaces between the IP and the host name is so important under windows 7       localhost

Under vista, a tab works perfectly, but under windows 7, it seems that it must be 8 spaces

  • To be honest, I haven't really messed around with hosts file since moving to 7, (do it all at the DNS server). Good advice if accurate - +1 Sep 27 '09 at 17:13
  • Unix requires any whitespace to be present. While not very surprising, Windows moving away from that format is kinda unusual. (I haven't tried Win7 myself.)
    – user1686
    Sep 27 '09 at 17:50
  • 1
    This is not accurate. I'm on Windows 7 Home Premium 64bit. I don't have time to test for tab or other number of spaces, but I have entries that work with 6, 7 and 8 spaces.
    – JannieT
    Feb 24 '12 at 10:09
  • -1 because the number of spaces does not matter. You can also use tabs. At least that's how my win 7 box works. Jan 26 '14 at 2:34

I noticed it takes a certain amount of time to resolve on windows 7.

Also I only have one space separating " domain" and it works fine.

ipconfig /flushdns doesn't seem to make a difference just clear your cache and wait a few minutes it will eventually take effect.

if still have problems make sure you running notepad as admin when you edit file and saving.

  • The number or type (tab) of spaces between and domain does not matter, at least on my win 7 box. Jan 26 '14 at 2:33

Here is what i did, when that all above solutions failed. go to: C:\Windows\winsxs Search for "hosts" for me it is located at: C:\Windows\winsxs\x86_microsoft-windows-w..nfrastructure-other_31bf3856ad364e35_6.1.7600.16385_none_045b589158ae90da\hosts

right-click it>> properties>> security>> advance>> owner tab change ownership to administrators, next change permissions of the file to full control to administrators group.

Edit the hosts file with the entries.

Disable chrome's dns pre-fetching as it could cache ip addresses of many sites. Also check your internet settings and disable any proxy servers you are using.

  • This is a terrible idea. Never touch the WinSxS folder. I would also be very surprised if a hosts file there would be effective.
    – Daniel B
    Oct 19 '16 at 12:49

Your entry was correct but somehow I did some of experiments on myself. So what I did was to clear my browsing history from the beginning of my browser eg: Google Chrome, after I cleared out all of the history I closed the browser and re-launched it again and try to browse the website that you want to block.

(But make sure you edit or put already the entries of websites that you want block in the HOSTS file)

At first I edit the HOSTS file and block the website that I want then after that I open my browser without clearing its browsing history and thats it its not working hehe.


This is an old question but just today we had a situation where we noticed the host file being ignored. My answer is probably not applicable to the lot of you, but if I can help only one person from pulling out their hair, it was worth posting it.

In our case, we used notepad++ to edit the hosts file and couldn't figure out why none of the entries worked. Turned out notepad++ was saving the file with a wrong EOL (end of line) format. When we eventually opened the file in normal notepad, we saw one huge string on line 1. So it did nothing.

  • 1
    Notepad++ displays the line ending type in its status bar, by the way. You can also convert it.
    – Daniel B
    Oct 19 '16 at 12:49
  • @DanielB, you're correct. It wasn't notepad++'s shortcoming I was trying to point out but rather prevent someone from having the same oversight. Oct 19 '16 at 20:05

I think i just figured out why it does not seem to be working if you choose to test it with google and that is because our browsers change the address to https and as its a secure protocol it bypasses our trusted host file. but in fact its still working fine. As an example now obviously blocking hp.com is only as a test please undo after you confirm its working try adding www.hp.com dont worry about how many spaces as long as there is one it should block that address

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy