DEV Community


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.
##   localhost
# TO STAY FOCUSED broadcasthost
::1             localhost
# Added by Docker Desktop
# To allow the same kube context to work on the host and the container: 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 🇳🇱): 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)