Blocking Websites with /etc/hosts

Rather then make this block using /etc/hosts I'd suggest using a browser addon/plugin such as this one named: BlockSite for Firefox or StayFocusd for Chrome.

BlockSite

  ss #1

StayFocusd

                    ss #2

But I want to really use /etc/hosts file

If you must do it this way you can try adding your entries like this instead:

0.0.0.0   www.example.com
0.0.0.0   example.com
::0       www.example.com
::0       example.com

You should never add entries to this file other than hostnames. So don't put any entries in there that include prefixes such as http:// etc.


You need to flush your DNS cache. According to this article, you can do that by restarting the following services:

  • nscd
  • dnsmasq
  • named