I have used my hosts file (located in /private/etc/hosts) several months to block distracting websites during the work day. This worked all well until now. Today it suddenly stopped working.
Some sample lines from the hosts file:
I placed that text in the hosts file by the following steps:
sudo nano /etc/hosts
wrote the lines above, then ^O to write the file, Enter to confirm the filename and ^X to exit the editor.
Between the localhost IP and the domain name I have a tab. The line endings are Unix style (LF), and the weird part is that when I use the
ping command it seems to do its job properly:
PING facebook.com (127.0.0.1): 56 data bytes
64 bytes from 127.0.0.1: icmp_seq=0 ttl=64 time=0.137 ms
64 bytes from 127.0.0.1: icmp_seq=1 ttl=64 time=0.122 ms
64 bytes from 127.0.0.1: icmp_seq=2 ttl=64 time=0.118 ms
64 bytes from 127.0.0.1: icmp_seq=3 ttl=64 time=0.110 ms
--- facebook.com ping statistics ---
4 packets transmitted, 4 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.110/0.122/0.137/0.010 ms
But when I try to access facebook.com in Safari or Firefox I am still able to get to the web site. This is also the case for other website that I have blocked in a similar way. I have emptied the cache for both browsers, but this didn't solve the problem.
What can I do to solve this problem?
Update 1: I'm now checking all the websites I've blocked this way and found out that the behaviour is not consistent across different domains. These are the "time-waster" I'm blocking in /private/etc/hosts:
All sites from this list ping to
flabber.nl are unreachable by any browser, but
facebook.com are reachable.
I have tried restarting, this did not solve the problem. Before this problem I have not changed the system configuration by an update of some sort.
Three hours ago I could access
facebook.com through Safari and Firefox, now I can't anymore.
dumpert.nl are still accessible though. I haven't changed anything in the past three hours, just used Word and browsed the web with Safari.
Update 3: Now, four hours after the 2nd update the hosts file works as normal again. In the process off fumbling with the hosts file I removed the non-working entries and re-added them one by one, testing each one after it was added. I have no idea what was happening and can't run wireshark on the traffic anymore as there is no faulty behaviour I can observe.
Update 4: And the problem is back again. The same sites as in update 1 show the erroneous behaviour.
Everything again works as it should. I'll keep the solutions posted here in mind when I encounter the error again.