none
HOSTS FILE NOT WORKING

    質問

  • i Want to block few sites such as orkut, facebook, etc On my Computer.
    When i searched on net it was written as to edit hosts file & in the end of it put it like this

    127.0.0.1 orkut.com
    127.0.0.1 facebook.com

    So it will block all the sites mentioned in the HOST file in thE ABOVE FORMAT.
    i DiD the same, & then restarted the PC also.
    But in vain, it still opens all the sites even mentioned in the hosts file.

    So plsss. can anybody help me how do i block all these sites ???
    • 種類を変更済み dharmil007 2010年2月28日 5:35
    2010年2月28日 5:34

回答

  • An easy way to block sites is to use http://www.opendns.com/
    you can setup a free account and using the dyndns updater and block sites without mesing with the hosts file.

    If you have access to the router on the network you can also input the opendns servers IP as the default DNS servers
    and ALL the PC's which use the routers dhcp (DNS settings) will have those sites blocked as well.
    this allows you to have better control than hosts files as you can allow opendns to auto updated blockes sites which pump out malware / scareware..

    And you do know you must use a text editor to edit the host file and that you must save it back without an .ext right???
    • 回答としてマーク dharmil007 2010年3月1日 3:19
    2010年2月28日 12:10

すべての返信

  • Did you check that the Hosts file had in fact been changed? Ordinarily, you have to run Notepad as an administrator to change it.
    2010年2月28日 10:13
  • Did you check that the Hosts file had in fact been changed? Ordinarily, you have to run Notepad as an administrator to change it.

    Yup.
    I changed the Hosts File, using an administartor privilage.
    & added that 2 lines at the end of the file.
    But still it is not working.
    i Dont know the reason
    2010年2月28日 10:50
  • An easy way to block sites is to use http://www.opendns.com/
    you can setup a free account and using the dyndns updater and block sites without mesing with the hosts file.

    If you have access to the router on the network you can also input the opendns servers IP as the default DNS servers
    and ALL the PC's which use the routers dhcp (DNS settings) will have those sites blocked as well.
    this allows you to have better control than hosts files as you can allow opendns to auto updated blockes sites which pump out malware / scareware..

    And you do know you must use a text editor to edit the host file and that you must save it back without an .ext right???
    • 回答としてマーク dharmil007 2010年3月1日 3:19
    2010年2月28日 12:10
  • An easy way to block sites is to use http://www.opendns.com/
    you can setup a free account and using the dyndns updater and block sites without mesing with the hosts file.

    If you have access to the router on the network you can also input the opendns servers IP as the default DNS servers
    and ALL the PC's which use the routers dhcp (DNS settings) will have those sites blocked as well.
    this allows you to have better control than hosts files as you can allow opendns to auto updated blockes sites which pump out malware / scareware..

    And you do know you must use a text editor to edit the host file and that you must save it back without an .ext right???
    Yes.
    i Have saved the hosts file without an extension.
    i M not on network.
    i Need to block those sites just for my home-PC {thats only 1 PC}.
    This is the link of my HostS fIlE.iF u fEEl anything else is missing then pls. tell me.
    http://depositfiles.com/files/u0bcmjmol
    • 編集済み dharmil007 2010年2月28日 12:59 Link uPdAted
    2010年2月28日 12:58
  • sorry if you want me to view the host file you will need to unload to your skydrive account.

    opendns works fine for one

    2010年2月28日 14:10
  • sorry if you want me to view the host file you will need to unload to your skydrive account.

    opendns works fine for one

    http://cid-b8e86b24058a32ba.skydrive.live.com/self.aspx/.Public/hosts
    Here it is.
    i'VE uPl0AdEd iT to skydrive\
    yes opendns works f9, but it displays msg that URL has been blocked by opendns..
    ThAts 0k With me but PlS. just chk it out with hosts file & tell me wats the matter with it.
    Y is It not working
    • 回答としてマーク dharmil007 2010年3月1日 3:18
    • 回答としてマークされていない dharmil007 2010年3月1日 3:18
    2010年2月28日 14:16
  • The host file you uploaded works fine to block those site.
    I would check the location.

     open a cmd prompt with adminstrator rights and type in
    cd D:\Windows\System32\drivers\etc
    then do a dir to make sure the hosts does not have an ext.

    now do edit hosts and make sure that file has the changes you make, you do know you must exit I.E. and restart it before you test right.
    2010年2月28日 18:44
  • Yeah, I have the same problem as the OP - the damn thing doesn't work. There must be some sort of bug in Windows 7 they haven't found yet.


    (And spare me rubbish about using other DNS servers or if the file has extension)

    2011年6月30日 23:04
  • Same issue here on all my clients' PC's. Hosts file does NOT work in Windows 7. I have yet to find a single instance where it does.

     

    Edit to add: I'm running Windows 7 64-bit. The c:/windows/SysWOW64/drivers/ directory does not have an etc/ directory. I'm editing hosts as administrator. I'm saving it without an extension and confirming that it is of type "file" in explorer, not text file. My entries are entered there correctly. I have made no changes to the default host name resolution priorities, so the default should be to look at the hosts file, but in no situation have I seen that behavior actually happen.


    • 編集済み MonroeIT 2011年12月14日 15:44
    2011年12月14日 15:00
  • An easy way to block sites is to use http://www.opendns.com/
    you can setup a free account and using the dyndns updater and block sites without mesing with the hosts file.

    If you have access to the router on the network you can also input the opendns servers IP as the default DNS servers
    and ALL the PC's which use the routers dhcp (DNS settings) will have those sites blocked as well.
    this allows you to have better control than hosts files as you can allow opendns to auto updated blockes sites which pump out malware / scareware..

    And you do know you must use a text editor to edit the host file and that you must save it back without an .ext right???

    Okay, this may qualify as an answer to the question, but we are on a microsoft message board, and the title is "HOSTS FILE NOT WORKING"... and that is not an answer to the "topic".

     

    Apparently, the hosts file not working is a common issue for users in Windows 7.  I am still digging around for an answer; some said simply re-create the hosts file (maybe the vanilla one is corrupted).

     

    Anyone have  input that can help fix the HOST FILE NOT WORK question?

    2012年1月24日 22:16
  • Disable TCP/IP 4 and 6 (uncheck) on your adapter.

    Apply

    Recheck TCP/IP 4 and 6 on your adapter.

    Apply.

    Should be fixed. 

    Cheers

    Brandon

    • 回答の候補に設定 -sg- 2012年4月10日 12:15
    2012年3月12日 19:25
  • Anyone have  input that can help fix the HOST FILE NOT WORK question?

    I've been having the same issue, persisting over reboots and everything, but I had specified my own DNS servers in my network connection settings.  Changed that back to "auto" and it started working (ie: blocking) straight away.

    • 編集済み Noipster 2012年10月28日 9:48
    2012年10月28日 9:47
  • I had exactly the same problem right now. Somehow the system had no right to read it (even tough the system had read rights under properties->Security etc.).

    My solution was:

    • copy the content of the file
    • open an editor and paste the content in an new file
    • save it on the desktop as hosts file (without any extension)
    • Move it to c:\windows\systems32\drivers\etc (need admin rights)

    After it i flushed my dns

    • run command prompt (Windows+R -> cmd -> Enter)
    • type: ipconfig /flushdns
    • 回答の候補に設定 imp.freebird 2013年1月3日 21:10
    2012年11月28日 15:49
  • This is rather annoying.  It's changed just recently.  I'd been using a symbolic link between the hosts file location and where I kept my real file in my dropbox folder.  

    Now that isn't working right either.

    That was a wonderful time and aggravation saver.

    They must have changed something really core in how it even reads the file in order for it to not even honor a symbolic (nor hard) link any more.

     The interesting thing is that before I used Robert's solution, it would still honor the symbolic link after a flushdns. Recreating the file fixed the need for the flushdns but broke the use of the link even with the flushdns.

    Very odd...  

    Windows files can have an extra hidden attachment to them not normally visible.  I wonder if that's at play here.  I haven't thought of that extra attachment for years. At this point I forget what they are called but they are there for compatibility with files from other operating systems.  They are also how windows records that a file came from an unsafe zone like the Internet in order to display a warning.


    2012年12月20日 3:49
  • i Want to block few sites such as orkut, facebook, etc On my Computer.
    When i searched on net it was written as to edit hosts file & in the end of it put it like this

    127.0.0.1 orkut.com
    127.0.0.1 facebook.com

    So it will block all the sites mentioned in the HOST file in thE ABOVE FORMAT.
    i DiD the same, & then restarted the PC also.
    But in vain, it still opens all the sites even mentioned in the hosts file.

    So plsss. can anybody help me how do i block all these sites ???

    The hosts file, when configured this way, will only block facebook.com and orkut.com. It will NOT block www.facebook.com, or any other subdomain of facebook.com as they are considered separate hosts. The hosts file also does not support wildcards. You'll have to put in more entries for all the subdomains or find another solution. I suggest filtering at the router.

    2012年12月27日 22:22
  • I had exactly the same problem right now. Somehow the system had no right to read it (even tough the system had read rights under properties->Security etc.).

    My solution was:

    • copy the content of the file
    • open an editor and paste the content in an new file
    • save it on the desktop as hosts file (without any extension)
    • Move it to c:\windows\systems32\drivers\etc (need admin rights)

    After it i flushed my dns

    • run command prompt (Windows+R -> cmd -> Enter)
    • type: ipconfig /flushdns

    I had a same issue as first started by "dharmil007". I followed as mentioned above in BOLD & ITLAIC and now it works fine for me (sites r blocking). Sepcs---Win 7 x64, Internet connected through mobile hostpsot-3G simcard.
    2013年1月3日 21:17
  • Disable and renable TCP/IP 4 and 6 did the trick for me, thanks.
    • 回答の候補に設定 Jan Coppens 2015年1月19日 14:41
    2013年2月21日 0:59
  • A SOLUTION FOR WINDOWS, MAC, AND LINUX/UNIX hosts FILE:

    i was looking for the following key:

    HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\ServiceProvider

    when i came stumbling upon this page. i see from questions/answers that an end-to-end explanation might be in order for people looking to get a complete answer.

    in the registry block, supra, you will find the 3 prioritized keys (4 if you foolishly use netbios) that affect windows nameserving. the priority is the value and lower numbers are higher priorities. to make certain that the 'C:\Windows\System32\drivers\etc\hosts' file is processed before resolving through DNS nameservers, have the relative (actual values are unimportant) numbering like this (the usual windows defaults):

    DnsPriority REGDWORD 6

    HostsPriority REGDWORD 5

    LocalPriority REGDWORD 4

    if you have administrator privileges and are unfamiliar with editing the registry, hold down the windows key (between the left 'Ctrl' and 'Alt' keys) and press 'R'. this will bring up the 'run' dialogue where must be entered 'cmd' to get a DOS-type window. at the prompt just type in 'regedit' and 'Enter' and you are in business. drill down through the 'HKEY_LOCAL_MACHINE' tree, supra, until you reach 'ServiceProvider'. check out the keys and change if required (by double-clicking the key's name). if you have a netbios-type key, make certain its value is between the values of DnsPriority and HostsPriority. also, look at the keys under 'Parameters' which is a couple above 'ServiceProvider'. you probably do not have a key therein named 'DnsNbtLookupOrder'. if you do, make certain the value is '0' (zero) or your local netbios names will suffer a fruitless search through DNS before being resolved by a netbios lookup!

    do not worry whether you have to input numbers as hex or dec by keeping your numbers below '9'.

    this way the resolution first looks at the hostname of the system, then the 'hosts' file, and then finally uses DNS if the name is not previously found.

    close the 'regedit' window and keep open the DOS-type window, because we will use it later, infra.

    SUGGESTIONS FOR THE 'hosts' FILE ARE ANALOGOUS AMONGST WINDOWS, MAC, AND *NIX O/S's (the file location for MAC/*NIX is '/etc/hosts'):

    now some people have proposed utilizing the 'localhost' IP of 127.0.0.1 as a blocking IP in the 'hosts' file, but the best and internally quickest solution is to use the "nowhere" IP of 0.0.0.0. one further step that pretty much remains undocumented (in windows, anyway) is that some people point out that just blocking a domain (xyz.com, for instance) will not block such a common DNS CNAME rec as www.xyz.com or actual A/AAAA DNS recs for hosts (sub-domains) such as now-ive-got-you.xyz.com. this is quite true, but the solution is quite simple. at any stage where you want to cut off the resolution (re-directed to 0.0.0.0), just put a leading dot. thus, '.xyz.com' will block xyz.com itself and all sub-domains as well. if you want to permit anything from xyz.com EXCEPT the 'porn' host just use '.porn.xyz.com' and that host and any further sub-domains will be blocked but everything else will pass.

    EXAMPLES:

    '0.0.0.0 xyz.com' blocks only this very domain and all sub-domains will pass such as porn.xyz.com.

    '0.0.0.0 .xyz.com' blocks this domain and ALL of its sub-domains such as abc.xyz.com and asd.porn.xyz.com.

    '0.0.0.0 .porn.xyz.com' blocks ONLY the 'porn' sub-domain and any of its sub-domains.

    '1.2.3.4 .xyz.com' directs this domain and all its sub-domains to IP 1.2.3.4.

    the 'hosts' file was the granddaddy of DNS back when anywhere you wanted to go had to be found in the hosts file. well, it did not take long before maintaining the hosts file was a full-time job and the founding of DNS an absolute necessity. one can still use this file for its ultra-high-speed name resolution which is usually at least a 1,000 times faster than DNS. so, drop in those places you visit fairly frequently if you so desire. consider this as a sort of manual "bookmarking" of IP's that will survive the regular DNS caching limits.

    NOTE: if you cannot save back any 'hosts' file changes, you have run the editor you are using without 'administrator' privileges. do a copy of the whole file (ctrl-A then ctrl-C), close the editor, and then right click on your editor and select 'run as administrator'. reload the hosts file and then paste your whole file over the contents [ctrl-A and then ctrl-V and then ctrl-S (to save on the spot)]. make sure that any changes to the 'hosts' file gets saved on your system as just that: not with an extension like '.txt' et cetera. you can check it by pasting the directory part of the link, supra, into the address bar of your 'explorer' file manager window and visibly checking it out to make sure it just says 'hosts' and the modified time is right now.

    now that you have finished everything, go back to the DOS-type window and enter 'ipconfig /dnsflush' and 'Enter' so that the DNS cache is wiped out and your new settings immediately take effect. in some cases it is also wise to reset TCP on your NIC and is mandatory if you have changed registry settings. so, from the 'start' menu do -> settings -> network connections so you will get into your own network which will be the hardware (NIC) you use for the Internet connection. in that dialogue box click on 'properties' to bring up the various sub-systems that are operating for your connection. un-check the two (2) items that end in 'IPv6)' and 'IPv4)' by clicking on the check box. this will disable them when you click 'OK'. this takes you right back to the status dialogue and you click the 'properties' again and just go back and click the check box for the items you just un-checked and then click 'OK' to re-enable them. click 'close' to get out of the status dialogue box and everything should be "right as rain"!





    2013年8月23日 1:24
  • check your proxy settings. had the same issue, turned out that I was using some proxy settings. 
    2013年9月16日 16:47
  • That was the case for me. If you are using a proxy, in addition to creating the HOST entries you also need to add the entries as Exceptions in the IE proxy settings.
    2013年10月7日 12:03
  • All,

    I came across this thread when having the same issue described here, but found a different solution.

    It was an error in my HOSTS file that I had not spotted.

    The IP address that I was given had leading zero's, which stopped it from working.

    As an example I was using 123.012.012.123 which did not work.

    Changing this to 123.12.12.123 worked a treat.

    it took a bit of finding, so I hope this saves somebody some time!

    Taff

    • 回答の候補に設定 comarc 2014年2月26日 12:50
    • 回答の候補の設定解除 comarc 2014年2月26日 12:50
    2014年2月1日 13:00
  • You must check your antivirus also.

    Sometimes antivirus software (like Avira) block hosts file when it was edited.

    2014年2月26日 12:52
  • You need to make sure that the hosts file does not have extension. When you edit it, Windows may add .txt to it.
    2014年5月6日 18:04
  • After trying all of the proposals here, I can add my specific case:

    I WAS USING THE WRONG EDITOR!

    Use Notepad, since it adds cr+lf for each newline. I used a Unix-style editor (Notepad++/Ultra-edit,...) and they inserted only the lf character. Is looked ok when viewing with these editors.

    After opening in Notepad it finally dawned on me - everything was in a single line, as far as Microsoft software interprets it.

    So, USE VANILLA NOTEPAD!

    Hope this helps somebody.

    2014年9月10日 14:40
  • My son asked me to do this to block Youtube so he could concentrate on his revision. I found that I could make the block  work when I removed the comment marker, the #, from the line #127.0.0.1 localhost.
    2015年1月27日 11:32
  • I had a similar problem, and had edited c:\windows\systems32\drivers\etc\hosts (without any extension). I checked and rechecked, and while Ping then worked correctly (bringing me back "Pinging stupid_scam_site.biz [127.0.0.1] with 32 bytes of data:" "Reply from 127.0.0.1:..." etc. However, Internet Explorer would still bring up the site I wanted to block. Doing the disable/enable for TCP/IP 4 and TCP/IP 6 for each of the adapters on my machine (including Bluetooth) solved it. Thanks for the hint.  


    Gardoglee

    2015年4月29日 23:17
  • Hi all, thanks for all the helpful information above!  I was able to get the host file changes working to block an undesired web site.  Here's some suggestions that might help people.  Running Windows Home Premium SP1.

    1.  You may need to make permissions changes to be able to edit the hosts file.  Those are described well in other places.

    2.  Contrary to a post above, entries in the hosts file appear to only match that single hostname, and there is no global matching.  So an entry for this domain

    127.0.0.1 googleleadservices.com

    does not affect the lookup of sub entries such as www.googleleadservices.com .  To block other hosts, you need to list those specific hostnames in the hosts file as well.  Such as adding

    127.0.0.1 www.googleleadservices.com

    3. Open a command window and run "ipconfig /flushdns" after you make changes to the hosts file.

    4. In the command window use "ping" to test the lookups.  Ping should resolve the intended 127.0.0.1 for the hosts you are blocking

    5. Looking at my registry settings, the defaults had the host file being checked before DNS lookup (the lower numbers are the higher priority).  So I didn't have to make any registry changes.

    6.  Once ping is resolving the hostname correctly, then test in a browser.  You may need to clear your browser cache and exit the browser before testing.  There may also be advanced settings in the browser that you need to change.  For example, Google Chrome has an advanced setting under Privacy "Use a web service to help resolve navigation errors" that is checked by default.

    7. For the network adapter properties I did check/uncheck the services for TCP/IP 4 and TCP/IP 6.  However, that didn't appear to make any change in behavior in my case.

    2015年6月13日 21:30
  • There is also a windows service that causes hosts to fail. You have to disable it. It gets enabled by users sometimes when they enable or try to view network in explorer. Pretty sure some folks have had luck disabling the dns service. Despite claimed that it only caches it does allow the order of lookup to be changed. 

    So basically you have to not only check the quality of the hosts file but you have to check lookup order, flush cache if you have tried to look up names. Then look at disabling dns client service. 

    2015年7月11日 2:07
  • Yes, Yes, finally!  I think it was disabling and re-enabling TCP/IP 4 and 6 that finally did the trick.

    I previously had problems saving the host file, tried to Run as Administrator, but that option was nowhere to be found (spent a while trying to fix that, gave up).  Instead, I edited the securities for the host file - Right click on the hosts' file, choose Properties -> Security and make sure all the boxes are checked for my user account (pretty instructions here: http://www.wikihow.com/Block-a-Website-in-All-Web-Browsers - step 6).  Maybe that's super basic, but I thought it might help someone else out there.

    Also, my Network Connections was not found under Start Menu ->Settings ->Network Connections.  Windows 10 gives me this altered Settings Menu that is really obnoxious.  However, I found it by typing View network connections in the search box on the taskbar (instructions here:  https://support.microsoft.com/en-us/help/15089/windows-change-tcp-ip-settings).

    Now that I have proven a test, I guess I'll have to go back through with the list of sites...

    2017年2月9日 16:14
  • Disabling IPv6 solved this for me.
    2018年5月12日 2:23
  • Don't worry, it's 2018, it's Windows 10 and HOSTS file is still not working.

    2018年9月10日 18:35
  • I tried to test the host on 2 network. On IPv4 it was ok, but on IPv6 it did not work. So u think that's the problen. Just turn of IPv6 in your network
    2018年9月30日 9:50