DEV Community

Boots
Boots

Posted on

1 1

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

Enter fullscreen mode Exit fullscreen mode

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.

Heroku

Built for developers, by developers.

Whether you're building a simple prototype or a business-critical product, Heroku's fully-managed platform gives you the simplest path to delivering apps quickly — using the tools and languages you already love!

Learn More

Top comments (0)

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

👋 Kindness is contagious

Engage with a wealth of insights in this thoughtful article, valued within the supportive DEV Community. Coders of every background are welcome to join in and add to our collective wisdom.

A sincere "thank you" often brightens someone’s day. Share your gratitude in the comments below!

On DEV, the act of sharing knowledge eases our journey and fortifies our community ties. Found value in this? A quick thank you to the author can make a significant impact.

Okay