M HYPE SPLASH
// updates

Block websites with /etc/hosts [duplicate]

By Emily Wilson

So I tried blocking some websites for obvious reasons but I can still keep going to these sites even when I 'supposedly' blocked them.

I've edited the /etc/hosts file so it looks like this (example being Facebook)

0.0.0.0
0.0.0.0 facebook.com
0.0.0.0 

Yet I can still access Facebook. What am I doing wrong?

EDIT: Only Chrome seems to block out the website, though I can still access it trough Safari and Firefox.

I'm running OS X Yosemite

8

1 Answer

Use the following instead:

127.0.0.1 facebook.com
127.0.0.1 

The IP address 127.0.0.1 is the localhost, aka local loopback, address for your system. By using 127.0.0.1, you are telling your system that facebook.com's IP address is the address of your system itself, effectively making FaceBook unreachable, since the system will get the IP address for the site from the hosts file rather than performing a DNS lookup. The first entry you put in the file, , doesn't belong there. The file provides a static mechanism for translating a fully qualified domain name (FQDN) to an IP address, so should only contain FQDNs or host names with associated IP addresses, not those prefixed by a protocol, such as HTTP, HTTPS, FTP, etc.

5