質問

I'm having a hard time geting Windows to take into account a new entry in my hosts file.

I tried adding this line:
199.229.249.151 models.db

To the hosts file found here:
c:\windows\system32\drivers\etc\hosts

When I save the file and try to reach the host with a browser, I'm getting a "host not found" error. I tried setting the "read-only" file attribute to the hosts file -- same result. I tried flushing the DNS cache, but nothing changes.

It seems Windows is not reading my modified hosts file at all, or at least, not taking in account my new entry.

What am I forgetting? What else could I try?

Are there specific requirements or rules to follow to ensure that Windows can always properly detect a change to the hosts file, read and parse its contents, and immediately take into account changes when using a browser or ping to test via the command-line?

役に立ちましたか?

解決

I ran into same issue and after checking lot of things, the issue ended up being the line endings, I had change the line endings to Windows format and it worked.

他のヒント

I ran into this problem once, The problem is Windows ignored the host file and I fixed it by:

  1. Copy the hosts file from C:\Windows\System32\drivers\etc to somewhere like Desktop
  2. Remove the hosts file there
  3. Copy the copied hosts file back to C:\Windows\System32\drivers\etc

I don't know why but it's fixed.

Automatic proxy server configuration scripts override the hosts file. To disable the automatic configuration script:

  1. Press Windows key and type Configure proxy server
  2. Click LAN settings
  3. Uncheck Use automatic configuration script

LAN settings

  1. Try ping localhost.

    if it works, then something wrong with ip or your entry. If it does not, hosts file is bad. Pay attention where it goes. It might try ipv6. That still means that hosts file is broken.

  2. Remove everything from it and leave only your entry or localhost. Single line only, nothing else at all! Not even line breaks. Just stash it aside somewhere until problem is resolved.

    If it works, then there's an entry that breaks things. Try converting line endings to windows format, might help. Usually it's white space that messes with things because it's hard to notice.

Open Notepad > Start Open Notepad > Open as administrator.

Save it at some location as ANSI hosts file (Not .txt extension, select all files and name it as hosts)

Copy all the hosts files entries and save it.

Finally copy the hosts file copied at the desired location say : C:\tempfolder\hosts to c:windows\system32\drivers\etc folder.

I encounter the same issue, and find my host is unicode, after change it to ANSI, the issue is fixed

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top