dns - Hosts file keeps being ignored in Windows 7
2014-06
Something keeps happening to my hosts file (%SystemRoot%\System32\drivers\etc) which means that Windows 7 ignores it.
I use it as part of the process of creating Virtual Hosts for WAMP e.g. website.dev and pointing it to 127.0.0.1
I frequently find that these .dev entries no longer respond (I also add example.com to the list) do not resolve in the way the hosts file is defined.
The hosts file still looks correct and I have attempted to Diff it against another copy and there doesn't seem to be any difference at all.
It seems like something installed on my computer is subtly corrupting the file (or at least making it unusable by Windows DNS system).
How can I monitor the file to see what accesses it and how it is being changed?
I updated some entries in the hosts file at C:\WINDOWS\System32\drivers\etc
. As a test, I decided to make Google point to 127.0.0.1
.
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
127.0.0.1 localhost
::1 localhost
127.0.0.1 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?
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.
An addition to @wil's answer.
the spaces between the IP and the host name is so important under windows 7
127.0.0.1 localhost
Under vista, a tab works perfectly, but under windows 7, it seems that it must be 8 spaces
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.
win 7 firewall control common domain name and does not override them with your hosts file.
so that localhost works, instead google.com no.
so just disable windows firewall service, and restart pc.
bye