DEV Community

Boots
Boots

Posted on

My COVID-proof /etc/hosts file

There's a point at which the news ceases to serve you, and only feeds the part of your brain that wants to reduce uncertainty.

I have reached that point.

Unfortunately, the world is extremely uncertain right now. And I just gotta learn to live with that.

First, though, I wanted to break the habit of checking the news as often as I was. I figured I could, in the short term, block the news-related sites that were distracting me most often, e.g.: Twitter, The New York Times, and The Washington Post.

To block these sites, I reached for an age-old trick: Modifying /etc/hosts to map certain urls to localhost (example below).

##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting.  Do not change this entry.
##
127.0.0.1   localhost
# TO STAY FOCUSED
127.0.0.1 twitter.com
127.0.0.1 www.twitter.com
127.0.0.1 mobile.twitter.com
127.0.0.1 www.mobile.twitter.com
127.0.0.1 nytimes.com
127.0.0.1 www.nytimes.com
127.0.0.1 washingtonpost.com
127.0.0.1 www.washingtonpost.com

255.255.255.255 broadcasthost
::1             localhost
# Added by Docker Desktop
# To allow the same kube context to work on the host and the container:
127.0.0.1 kubernetes.docker.internal
# End of section

So, instead of the stream of "holy sh*t" headlines I was checking every hour, I now see (pardon the Dutch πŸ‡³πŸ‡±):

nytimes.com shows no server connection possible

This is what you'll see, except probably not in Dutch πŸ‡³πŸ‡±

Works like a charm!

If, like me, you're on a Mac, you'll want to run sudo killall -HUP mDNSResponder afterward editing /etc/hosts in order to flush your DNS cache.

Also, I should note that messing up this file can have bad consequences... so make a copy before you toy with it, okay?

Otherwise, stay inside and enjoy your weekend.

✌️


Also, as a post script, I should mention that my new deal with myself is only to check this Axios one-pager on pandemic updates. We'll see how that goes.

Top comments (0)