- Open the Hosts file:
-
Windows
- Press the Windows Key + R.
- Type notepad C:/Windows/System32/drivers/etc/hosts and press Enter.
-
Mac
- Click the Finder icon in the Dock.
- On the top menu, click Go, then Go to Folder…
- Type /etc and press Enter.
- In the folder that appears, open the file named “hosts”.
- Find the line that says 127.0.0.1 localhost.
- To block a website (i.e. test.com), then type the following lines underneath:
127.0.0.1 test.com
127.0.0.1 www.test.com - Add as many sites as you like by putting 127.0.0.1 followed by the website; preferably with and without the www.
- Click File, then Save.