Since I spend too much time on websites such as 9gag.com and the like, I decided to try and block them by modifying the hosts file on my rooted Nexus 5.

So I created a new hosts file using notepad++, which looks like this : board.4chan.org 4chan.org 9gag.com www.9gag.com www.4chan.org

etc., saved it as a file without extension, and replaced the original "hosts" file found in system/etc with the new file. However, it does not have any effect and I can still access all those websites as easily as before. I'm using Chrome as my browser.

I checked that the new lines are LF and not CR+LF (read somewhere that it could make the hosts file work not properly) and that the file has no extension (File Explorer shows it as a "file", that's all). When I try to edit the hosts file with an app called Hosts Editor, it looks like everything is good and like my device should redirect the websites I'm trying to reach to localhost.

So my question is : why is this not working? What have I done wrong?

Thanks a lot!


2 Answers 2


To expand on the update that was made by the OP:

Chrome stores its own DNS cache for sites that you have visited. This cuts down on DNS resolution time when browsing sites that you have recently visited. However, this happens before the hosts file is checked for DNS resolution (so your new hosts entries will not be checked if they are in the Chrome DNS).
Therefore, you need to clear out Chrome's DNS cache. You can go to
chrome://net-internals/#dns and clear it out from there.

The order in which Chrome checks for DNS (from first to last) is:


The answer for anyone interested: after seing that I could not access the blocked websites when in incognito mode, I deleted all of Chrome's data (by going to the Application details and hitting "Clear all data" - I supposed that's how it's said in English but I'm not quite sure). Now, the websites are blocked, so everything is fine. I don't know if I'm supposed to delete this question now that I've solved it but maybe it will be useful to someone if they stumble upon it.

  • Also works if you clear cache and site data only for the site you are trying to block, thanks, you saved me a lot of time
    – Belzebub
    Aug 4, 2020 at 19:56

You must log in to answer this question.

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