If you find yourself constantly checking Facebook or other distracting websites, there are a few things you can do to block them. First, make sure your computer is up to date with the latest security software. This will help protect you from viruses and other malware that could steal your information or hijack your computer. Next, install an ad blocker. These programs block ads from appearing on websites you visit, which can help reduce your overall exposure to advertising. Finally, consider using a screen saver or sleep timer to block specific periods of time during the day when you’re likely to be more distracted. By setting limits on how long you’re allowed to spend online each day, you can better control how much time you spend on Facebook and other sites that may be harmful to your productivity. ..

How to Block Distracting Websites

We will be using two methods today for blocking distracting websites: a manual system-level tweak, or dedicated third-party software. It should be relatively easy for most people to use the manual tweak on desktop operating systems like Windows, macOS, and Linux. Depending on your smartphone, an app might be required on mobile.

Manually blocking a website requires you to edit your computer’s hosts file. Before DNS, the hosts file was used to link domain names and IP addresses so that when you tried to access a domain (like howtogeek.com), the correct server received and served the request.

You can use your system’s hosts file to manually reroute domain name requests to other servers. This is often used in web development for testing websites before they go live. Blocking a website is as simple as rerouting domain requests to 127.0.0.1 or localhost, which is your own local machine’s IP address. You could use 0.0.0.0 or any “bad” IP address here.

The benefit of blocking a website manually is that it remains blocked until you edit the file again. If you’re looking to block Facebook or Twitter permanently on your work computer, this is a great option. If you use this method and want access to these websites, you’ll need to edit the hosts file again.

If you’d rather retain access to these websites during off-peak hours—for example, on your lunch hour or after work—this might not be ideal. Instead, you can use apps that can block websites of your choice on a schedule or for a set period only. We’ll look at both methods below.

Manually Block Websites Using the Hosts File

While the method for accessing the hosts file differs between operating systems, the changes you’ll be making do not. The changes you make depend on which website you’re trying to block. To block Facebook’s desktop and mobile websites, you’d add:

127.0.0.1 www.facebook.com

127.0.0.1 m.facebook.com

These lines tell your computer that “www.facebook.com” is found at 127.0.0.1, which is your computer’s local address (any “wrong” I.P. will suffice). Regardless of which browser you use, your computer will be looking in the “wrong” place for Facebook’s servers, and the domain simply won’t work.

You can use the # symbol to add a description after the domain to remind yourself of why you have made the changes—for example, # blocks facebook.

The # symbol instructs the operating system to discard the rest of the line. You can use it to toggle your redirects by simply adding the # to the beginning of the lines. This allows you to quickly toggle whether Facebook is blocked or not. To quickly disable your Facebook block, you’d add # like this:

127.0.0.1 www.facebook.com

127.0.0.1 m.facebook.com

It’s a good idea to make your changes on a new line at the end of the hosts file. Take care not to change any other entries unless you know exactly what you’re doing.

Editing the Hosts File on Windows

You’ll need to run Notepad as an administrator to have the correct privileges to make changes to system files. You’ll need an administrator account for this.

Using Windows 10 or 8: Use the search box on the taskbar to look for “Notepad.” Right-click the “Notepad” shortcut and choose “Run as administrator.”

Now, click on File > Open and paste c:\windows\system32\drivers\etc\hosts into the Open window and hit enter. You can now block whichever domains you want using the instructions above. When you’re done, click File > Save to save your changes.

Using Windows 7: Click on Start, followed by Run, and paste the following into the “Open” field: notepad c:\windows\system32\drivers\etc\hosts. Windows 7 will open the file with administrator privileges so that you can use File > Save to keep your changes.

Editing the Hosts File on macOS

Just like on Windows, you’ll need to use administrator privileges on macOS to make changes (You’ll need an administrator account for this.). On a Mac, changes are made using the command line app Terminal and your system’s built-in text editor, nano.

First, launch Terminal, either by searching for it or by finding it under Applications > Terminal. Type or paste, and then execute the following command to open your hosts file in nano: sudo nano /etc/hosts. Type your account password, followed by Enter, to confirm.

Add any lines that you would like, taking care not to change any existing rules. Once you’re done, you can save your changes using the WriteOut command, accessed via the keyboard shortcut Control+O.

If you want to abandon without saving your changes, use the Exit command shortcut Control+X.

Editing the Hosts File on Linux

On Linux, follow the same steps as you would on macOS. Both Linux and macOS have the nano text editor and a hosts file located at /etc/hosts. Just launch a terminal, run the same sudo nano /etc/hosts command, add the information in the same way, and press Ctrl+O when you’re done.

Manually Block Websites on iPhone & iPad

It’s not possible to access the hosts file on an iPhone or iPad without modifying the firmware (also known as jailbreaking). Apple makes it possible to block specific websites, but not without also blocking what it terms “adult websites.”

In addition to blocking anything that Apple deems risqué, this setting also removes private browsing mode from Safari. For these reasons, it might not be a good long-term solution. Fortunately, once you’ve set it up, you can turn it on and off relatively easily.

To block a specific website on your iPhone or iPad, first, launch Settings, and then tap on Screen Time.

On the next screen, look for “Content & Privacy Restrictions,” and then tap on it.

Enable the “Content & Privacy Restrictions” toggle at the top of the screen and enter a passcode if prompted. This will be a Screen Time passcode that you have set up in the past. Hide this passcode from anyone you don’t want removing your restrictions, such as children.

Next, tap on “Content Restrictions,” followed by “Web Content.”

Now, tap on “Limit Adult Websites,” and under “Never Allow,” add any websites that you might want to limit. You can now back out of this menu. Finally, delete any apps associated with the service that you’re trying to block (Facebook, Twitter, and so on).

You can disable your block quickly by revisiting Settings > Screen Time > Content & Privacy Restrictions and disabling the “Content & Privacy Restrictions” toggle at the top of the screen. Learn more about securing your device using Screen Time restrictions.

Block Websites Using an App (Including Android)

If you don’t fancy using a text editor to change your hosts file manually, you want to schedule your block, or you’re using an Android device, software can handle this process for you.

Blocker Apps for Android

On Android, Google Family Link allows similar control to Screen Time on iOS. This is perfect for limiting access to websites and services on children’s devices, but you could also use it to restrict your own device, too. Failing that, BlockSite is a popular third-party solution designed purely for blocking distracting websites.

Blocker Apps for Windows

A small free app called FocalFilter allows you to set up a block list, which you can invoke for a set period. It’s a simple way of dealing with distracting websites, and it works with Windows 10, 8, 7, Vista, and XP.

If you want something a little more automated, look at Cold Turkey (free version available). The app is available free of charge, and the free version will let you block websites. However, you’ll need to pay the $39 registration fee to access advanced features like scheduling and application blocking.

Blocker Apps for macOS

On macOS, you can use the free app SelfControl to set up a block list, and then block those websites for a duration of your choosing. Just like FocalFilter on Windows, it’s simple and effective, but lacks the advanced scheduling features of an app like Cold Turkey (also available for macOS), which costs $39.

Blocker Apps for Linux

Free app Chomper appears to be the best purpose-built tool for blocking websites on Linux. It’s a command-line tool that provides more granular and nuanced controls over your blocklists than simply editing the hosts file.

You can use Chomper to set up timed blocks and switch between different blocklists on the fly, all with a few text commands. Read the Chomper documentation to learn more about the app.

Improve Your Productivity

Blocking websites is just one thing that you can do to try and improve your productivity. But temptation is never far away, especially with mobile apps making it so easy to check your feed throughout the day.

There are other things that you can do to be more productive, including using multiple monitors and tweaking your Mac.

RELATED: How to Use Multiple Monitors to Be More Productive