59

I'm using hostsblock together with dnsmasq on Arch Linux to block some websites, one of them is facebook.com and www.facebook.com.

I know everything is working properly because a simple ping to facebook.com (or www.facebook.com) returns 127.0.0.1. Also, if I access these websites from Midori, a blank page is returned (this is an expected behavior, since I'm algo using the kwakd daemon to return blank pages on localhost).

Only Chromium seems to bypass my blocklist. Accessing facebook.com from it makes me go straightly to the facebook homepage.

After cleaning up everything (Ctrl+Shift+Delete) since the beginning of time and restarting Chromium, I get the desired behavior (= cannot access Facebook).

Although, after a while (I'm not exactly sure what causes this), Chromium ignores again my local dnsmasq DNS and successfully access the facebook Homepage.

I read something about the caching and pre-fetching of DNS queries of Chromium, but I'm not sure how to disable it.

Question is: why is Chromium bypassing my local DNS, and what can I do to stop it?

3
  • 2
    Are you using a proxy? When you use a proxy, the DNS requests are performed on the proxy.
    – Zoredache
    Mar 2, 2014 at 21:03
  • No, I'm not using any proxy, hostsblock doesn't require one.
    – thiagowfx
    Mar 2, 2014 at 21:11
  • I tried the methods of the answers below, but somehow Chromium is still obtaining the IP addresses… Are there some hardwired addresses in Chromium?
    – Geremia
    Aug 16, 2017 at 22:00

4 Answers 4

43

The majority of references about this subject are old. If you have an old version of Chromium, follow edvinas.me answer.

For current versions of Chromium (at the time this post was written: 33rd), here is what you should do:

  1. Go to chrome://settings
  2. Click on "Show advanced settings..."
  3. Unmark the Predict network actions to improve page load performance box.
  4. Check if the DNS prefetching is really disabled by going to chrome://dns. You should see there something like DNS pre-resolution and TCP pre-connection is disabled. If the prefetching is not disabled, you'll see some tables there.

Update

For newer versions of Chrome (at the time of this update: 55th), the third item is worded as: Use a prediction service to load pages more quickly.

Reference

4
  • 4
    chrome://dns doesn't exist anymore. Nov 25, 2019 at 16:34
  • with Chrome v85, goto chrome://settings/security and scroll-down to Advanced - Use Secure DNS, then choose 'with your current service provider'; or Custom, and type whatever DNS you want Chrome to use; or disable Use Secure DNS altogether.
    – user1082
    Sep 6, 2020 at 17:18
  • I use Little Snitch on my mac and discovered that Snitch rules for blocking facebook domains were no longer being respected by Chrome (v85). I eventually found the solution was to change Chrome's Secure DNS setting to my own ISP, instead of Google Public DNS. facebook domains are once again blocked in Chrome… phew!
    – user1082
    Sep 6, 2020 at 17:36
  • This answer is not useful anymore. @user1082 that does not reply OP's question: how to make chrome respect /etc/hosts Jun 18, 2023 at 8:51
29

Updated Answer

Make sure you clean Chrome's cache. Type this in address bar:

chrome://net-internals/#dns

Then click Clear host cache button.

Old Answer

Chromium is using Google's internal DNS by default (8.8.8.8 and 8.8.4.4)

To disable it:

  1. Click on Tools menu (a little wrench icon), then go to Options.

  2. ‬Click on the Under the Hood tab.

    ‪3. ‬Under “Privacy” section, untick the check box for Use DNS pre-fetching to improve page load performance.

    ‪4. ‬Click on the Close button.

    ‪5. ‬Refresh to reload the web page.

6
  • 1
    What you said would only apply to old versions of Chromium / Google Chrome. Newer versions do not have this setting anymore (neither "Under the Hood"). Maybe the new setting is "Predict network actions to improve page load performance"? Sadly, this does not mention any DNS, so I'm not sure.
    – thiagowfx
    Mar 2, 2014 at 20:27
  • I have updated an answer on how to clear Chromium's DNS cache. Please have a look, I hope it helps.
    – ek9
    Mar 2, 2014 at 20:54
  • Thanks! Your new answer is the best way to clear a recorded DNS (instead of cleaning everything up as in Ctrl+Shift+Delete). But to get rid of the problem permanently, I think my own answer fits better (I still have to test a little more just to be sure).
    – thiagowfx
    Mar 2, 2014 at 21:00
  • Well if you just disable that without clearing cache - it will not work until cache expires. After cache is cleared, I do not think that Chromium should be able somehow to pre-fetch the real-IPs. Even if pre-fetch is on it will prefetch the blocked values. Anyway, at least it seems you have sorted it out.
    – ek9
    Mar 2, 2014 at 22:03
  • 2
    "chrome://net-internals/#dns" -> clear, is not working.
    – Totty.js
    Aug 30, 2018 at 6:16
2

One other obscure possibility is that your system is setup to use an automatic proxy *.pac file. This would normally be the case if you were issued a computer in a corporate environment and the *.pac file is telling your browser to go through a proxy to resolve the URL. This takes priority over your /etc/hosts file and if the *.pac file has a rule in it to return PROXY if nothing matches then it will appear that Chrome is not honoring the /etc/hosts. This will normally be the case if your command line is working as expected, e.g. dig, ping etc.

If you tried the other solutions and they don't work then check to see you don't have an auto proxy setup that Chrome is using.

1
  • 1
    This worked for me!
    – MediumOne
    Aug 20, 2017 at 8:25
-2

If you are using any VPN Proxy extensions for Google Chrome (like Betternet), you may likely encounter this problem. Disabling the extension solves the problem.

You must log in to answer this question.

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