How to Break the Habit Loop for Distracting Websites


The basic structure of a habit is cue → craving → response → reward:

  1. The cue is the context that triggers the habit, such as feeling bored or anxious.

  2. The craving is the feeling that you should take some action, such as reaching for your phone and opening up YouTube.

  3. The response is the action, such as watching a video.

  4. The reward is the result that reinforces the habit, such as the dopamine hit of novel content.

Weaken these four and the habit eventually fades. For example, if your phone is harder to reach, it'll be more difficult to act on the habit.

But since this is ostensibly a tech blog, here are some tech things you can do with the same effect:

Edit /etc/hosts

Your /etc/hosts file defines redirects for different websites. Redirecting a website to localhost (IP address, as is done here, has the effect of preventing you from visiting that website:


Yes, www is necessary if the site uses it.

If these changes don't take effect, run:

# macOS only
dscacheutil -flushcache

to flush the cache.

[iOS] Enable Content & Privacy Restrictions


Update — This doesn't work well. iOS allows block lists only as part of their "Limit Adult Websites" feature, which has false positives and can block legitimate sites based on keywords.

If you have an iOS device, you can also enable per-website restrictions:

  1. Go to Content & Privacy Restrictions in Settings.
  2. Go to Content Restrictions → Web Content.
  3. Select Limit Adult Websites (sketchy name, I know).
  4. Add whatever websites you want to block to the Never Allow list.

Does this work?

These changes are just speed bumps I use to remind myself that I probably don't want to be using this website. If I have a real need, I can easily circumvent these changes and use them when I need to.

If your problem is more serious, I've heard good things about Freedom, but I think someone could circumvent basically any content blocker if they were determined enough.


This post was written in ... 18 minutes?! Wow, I need to learn to be faster.