0

I run a web server e.g. python -m SimpleHTTPServer 80 or python -m http.server 80(which of those depends on python version), and I do echo blah >index.html to write an index.html with the text blah in it.

C:\Python27>start python -m SimpleHTTPServer 80


Serving HTTP on 0.0.0.0 port 80 ...

and it works

C:\Python27>curl 127.0.0.1
blah

C:\Python27>

Chrome picks it up

http://127.0.0.1 displays blah

My hosts file c:\windows\system32\drivers\etc\hosts

has these lines

127.0.0.1 rice.com
127.0.0.1 www.rice.com

And the hosts file works, for rice.com

in that if I tell chrome to go to http://rice.com, then it says "This site can’t be reached rice.com refused to connect."

But it's not picking up the web server when going through the hosts file!

So I can access http://127.0.0.1 in chrome and that works

but when I do http://rice.com it doesn't go to rice.com so the hosts file is doing something, or rather, it's having some effect.

but chrome doesn't get from http://rice.com to http://127.0.0.1

firefox also.

That was windows 7. I tried it on another laptop that happens to be running windows 10, and same thing happens.

I start the web server python -m http.server 80

And same thing.. If I do http://127.0.0.1 it sees it(contents of index.html). If I do http://rice.com then it says "site can't be reached. refused to connect".

8
  • I deleted my answer as regarding "Secure DNS", as it didn't help.
    – harrymc
    Commented Apr 30, 2022 at 20:41
  • well actually a wrong answer or answer that doesn't help, with some comments why, actually DOES help, because it is very relevant info relating to the question, that anybody else answering, or any other answers, can consider
    – barlop
    Commented Apr 30, 2022 at 20:42
  • OK, undeleted back. Hope it helps a bit.
    – harrymc
    Commented Apr 30, 2022 at 20:43
  • @harrymc well, do you have any idea why what I found was kind of the reverse of what you thought it might be? (undersatnding these things can help)
    – barlop
    Commented Apr 30, 2022 at 20:44
  • Seems fishy. I notice that "Use secure DNS" is only enabled when Safe Browsing is set to Enhanced protection - try to set it to a lower Safe level. Mine is set to "No protection".
    – harrymc
    Commented Apr 30, 2022 at 20:54

1 Answer 1

0

If in chrome://settings/security the option "Use secure DNS" is enabled, try to disable it and restart Chrome.

"Secure DNS" stands for "DNS over HTTPS" and is now enabled by default. It causes the browser to ignore all local DNS settings and do its own DNS lookups using a provider configured in the browser (by default probably Google) over a secure HTTPS channel.

This will prevent eavesdroppers or your ISP from tracking what sites you visit by monitoring your DNS lookups, but it will also disable your hosts file.

4
  • I will try that but as mentioned in the question, my hosts file is not being ignored
    – barlop
    Commented Apr 30, 2022 at 20:34
  • I tried it and things happen the other way around to what you mention(re whether the hosts file is ignored or not). i.e. When secure DNS is enabled, as it was, then the hosts file is not ignored. It refuses to load rice.com (the issue though is it doesn't load up my local web server). When I disable secure DNS, then it ignores my hosts file and just goes ahead and loads up rice.com
    – barlop
    Commented Apr 30, 2022 at 20:39
  • you mention that that you notice " that "Use secure DNS" is only enabled when Safe Browsing is set to Enhanced protection - try to set it to a lower Safe level. " And you mention that yours is set to no protection. . I notice that it is possible to be set to no protection and have secure dns to off. Mine was on enhanced protection. I just tried setting mine to no protection, and secure dns to off. , still same effects.
    – barlop
    Commented Apr 30, 2022 at 23:09
  • Very strange. I just added your two lines to my hosts file, and my Chrome has no difficulties reaching my IIS webserver via rice.com. I don't know why this is not working for you, but try (1) Running Chrome in Incognito mode (no extensions), (2) Disable temporarily your security software and firewall, (3) Uninstall Chrome, clean up and re-install (save bookmarks). This might give us some more information.
    – harrymc
    Commented May 1, 2022 at 8:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .