Block distractions with /etc/hosts
Lately social media has felt like an unending river of rage, angst, and bad news. It’s a sort of textual noise. This month, I decided to kill the noise, and take a much-needed social media break.
That doesn’t necessarily mean spending less time looking at screens I — like you — work, socialize, and stay informed on the internet. But it does mean shifting my attention away from my favorite timesuck: Twitter. I’ve enlisted the help of my hosts file to help me break my habit.
Most operating systems have a hosts file. OS X users (and users of most *nix systems) can find theirs at
/etc/hosts. You can edit it manually, but you’ll probably have to use
sudo to do it. Its contents will look something like this:
127.0.0.1 localhost 255.255.255.255 broadcasthost ::1 localhost
Roughly what this does is redirect requests for
127.0.0.1 is a special IP address that represents the requesting machine. In other words, visiting
localhost in your browser will direct your request back to your computer. Assuming that you aren’t running a local web server, you should see an error message.
We can take advantage of this routing to block access to our favorite time wasting sites. Decide which host names you want to block, and direct them to
127.0.0.1. In my case, that’s both twitter.com and api.twitter.com (so I can’t use the TweetDeck or Twitter apps either).
127.0.0.1 twitter.com 127.0.0.1 api.twitter.com
Any time I attempt to visit twitter.com from my laptop, I instead see the Chrome error page. Should I decide to return to Twitter, I can delete those lines or prepend them with a
# so they’ll be ignored.