No News is Good News – HOSTS File Hack for a Happier Life

The Guardian recently published an article arguing that overly-frequent consumption of “news” is bad for us: it misleads, increases cognitive errors, and may actually make us less healthy by constantly sparking our flight-fight responses.

Regardless of whether we’re slowly killing ourselves with news, it resonated with me because I realize that my consumption of news is bordering on obsessive, or at least it’s what I turn to first when I’m bored and find myself viewing the same landing-pages over and over mindlessly. Even if there is fresh content to entertain me, I can’t remember the last time The Huffington Post actually added value to my life. At the very least blocking these sites will improve my productivity. Consequently, I devised an easy tool to block news sites at the click of a button, and to turn them off again with another click.


By customizing your Windows-machine’s HOSTS file, you can block websites temporarily without any third party software. The file that maps web hostnames to IP addresses. Hostnames are the textual identifiers of network devices, for instance you can name a printer on your network ‘speedy’ or you can access a website at the host name ‘’. Websites’ hostnames are matched to IP addresses by DNS servers, but you can provide custom IP locations for any given hostname by customizing the HOSTS file. This can also be helpful for blocking ad servers (which I do with the help of the MVPS HOSTS file).

Creating the News-blocker HOSTS File

First, set up locations to store the modified HOSTS file and a default to un-block the sites when you run the script below. Create a folder C:\hosts with subfolders blockNews and default, e.g.:

HOSTS folder tree

Inside the /blockNews folder, create a new text file and enter the following:

# Required localhost

::1 localhost #[IPv6]
# End required

#start of lines to block news sites -- add your own too

#end of list

Add any other sites you want to block in the similar pattern – new line;; two spaces; the domain name (no wwww.). Save the file as HOSTS.txt, then close. Now rename the file to HOSTS without any file extension – approve the warning Windows pops.

In the /default folder create another new text file with the following lines:

# Required localhost

::1 localhost #[IPv6]
# End required

Just like the other HOSTS file, save as HOSTS.txt then rename as HOSTS without a file extension. If you want to block any non-news sites permanently, just add the sites to both files.

Write the Batch Script

The batch script will prompt the user to either block news sites, or restore the default HOSTS file. In either case, the custom HOSTS file is copied to the system HOSTS file location (C:/Windows/System32/drivers/etc/) where it overwrites any existing file.

In notepad, create a new file and enter the following:

@echo off

SET /P ANSWER=Enter 'n' to block news sites or 'd' to restore default.
echo You chose: %ANSWER%
if /i {%ANSWER%}=={n} (goto :block)
if /i {%ANSWER%}=={d} (goto :default)
goto :anythingElse
Xcopy.exe /y "C:\hosts\blockNews\HOSTS." "%SystemRoot%\system32\drivers\etc\"
News sites blocked
exit /b 0

Xcopy.exe /y "C:\hosts\default\HOSTS." "%SystemRoot%\system32\drivers\etc\"
Default restored
exit /b 1

echo No changes were made
exit /b 2

Save the file as blocker.bat. The file can reside anywhere – even on your desktop.

Run the Blocker

Replacing the HOSTS file requires administrator rights, so you will need to right-click your .bat file and select ‘Run as administrator’ and approve the system warning.

Run news blocker

The batch file will request the user to enter either ‘n’ for news blocking or ‘d’ for default. You can customize these values by editing the script above (right click your batch script and choose ‘edit’).

Blocker window

And there you have it. When the blocker is activated, it will refer all your blocks news URLs to the localhost, in which case your browser will tell you that the webpage is not available. Success.

CNN blocked

Use the same script to reverse the changes. If any problems arise that the script doesn’t seem to fix, you can easily restore the default HOSTS file by deleting C:/Windows/System32/drivers/etc/HOSTS and following Microsoft’s directions here.

Leave a Reply

Your email address will not be published. Required fields are marked *