Why is Windows not reading my hosts file?

Almaron picture Almaron · Jul 24, 2013 · Viewed 71.8k times · Source

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?

Answer

user3558019 picture user3558019 · Jan 18, 2017

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.