0

I'm specifying certain domains in my hosts file to block them. So redirecting a domain to 127.0.0.1 when i'm not running any web server on 127.0.0.1 will block that domain.

why does it take chrome two minutes to pick up that a domain has been blocked in the hosts file, and can that time be decreased a lot?

If I go to rice.com then it loads. (I used rice.com just as a test)

I then tried these lines in my hosts file to block the website from loading

127.0.0.1 rice.com
127.0.0.1 www.rice.com

Immediately after saving the hosts file, I go to rice.com in chrome, and it still loads.

But if once rice.com has loaded, I leave it for two minutes, as it is, then I try to reload it, then it says "rice.com refused to connect." So chrome finally picks up that the domain is blocked.

If I then edit the hosts file to unblock that domain, by commenting those lines, then chrome picks up immediately that it has been unblocked and goes there. So, for unblocking chrome is very responsive. (understandable, since if chrome can't load it I imagine it does everything to try to load it and part of that is checking the hosts file).

I tested this on Windows 7 and on Windows 10, same thing. (Apart from one of my tests on Windows 10 where it responded immediately picking up on a block. But other than that one time, Windows 10 seems to take a while to pick it up, but picked it up after 2 minutes, as Windows 7 does).

I have tried ipconfig /flushdns but I haven't noticed it making any difference

I'm wondering if there is any setting related to that two-minute delay and any way to decrease it?

Note- Somebody commented asking re Firefox. I tested on Firefox and firefox is worse. I had rice.com blocked in the hosts file and firefox saw that. Then I unblocked it. Chrome picks up immediately that it's unblocked, but firefox even after two minutes hadn't figured it out. Firefox took 4 minutes to notice that rice.com was unblocoked while chrome notices immediately. As for the other way, so, once a site loads, then the site is blocked, how long it takes chrome to realise is 2 minutes. How long it firefox to realise, well i've given firefox over 4 minutes before a refresh and it still hasn't figured it out

barlop
  • 25,198

1 Answers1

0

A few things to clear up first: The browser doesn't check the hosts file, the operating system does. Note (in case you don't already know) that you don't "block" a URL by adding it to the hosts file, you just specified the IP to your local machine which doesn't run the (any) webserver.

So if Chrome still connects to the website it means the website's IP is still cashed somewhere, even if it's gone from the machine's DNS cache. You probably need to clear the browser cache as well via chrome://net-internals/#dns, that will hopefully solve the problem. You can test this by pinging the URL after you entered it into your hosts file (the change should be immediate, if not, flush the OSs DNS cache ipconfig /flushdns, if it doesn't help the browser isn't the issue).

If the browser seems to remain the issue, try to reload the page bypassing the cache, or open the URL in an incognito tab that should bypass the cache as well.

Albin
  • 11,950