I tried to block Facebook on Chrome by changing the hosts file but to no avail. What could possibly went wrong?

  1. Modifying hosts file does not have any effect

I followed exactly what the op did and rebooted, but I could still have access to Facebook.

doesn't work I have root access

  • 1
    Your hosts file is completely broken. There should be no space after any dot in a hostname. Remember: It's facebook.com not facebook. com. The latter one assigns only facebook. to another IP. Any errors in the hosts file is silently ignored and that's it.
    – GiantTree
    Commented Apr 20, 2016 at 12:51
  • I'm guessing whatever keyboard you are using assumes the periods to be line ends and adds the space for you during the construction of these lines. Investigate how to turn that off while composing this file.
    – wbogacz
    Commented Apr 20, 2016 at 12:56
  • @GiantTree If you look at the second screenshot, that appears to have spaces too, in a place you wouldn't expect any. I suspect it's an awful font rather than spaces actually in the file.
    – Dan Hulme
    Commented Apr 20, 2016 at 12:57
  • As a plus to what @GiantTree said, I'll point out that lines 3 and 4 do nothing.
    – Grimoire
    Commented Apr 20, 2016 at 12:57
  • @DeathMaskSalesman depends on the local network. If one host has the hostname facebook (that's possible) then it's blocked as well. It's just not needed because there won't be a host with that hostname.
    – GiantTree
    Commented Apr 20, 2016 at 13:00

1 Answer 1


Just try adding these three hosts name and replace ip address


As I checked when typed facebook.com, the site will be redirected to m.facebook.com, so we won't be able to access.

You must log in to answer this question.