Block Sites on Your Computer

Webs-blocking options found in the preferences of browsers like Internet Explorer or Firefox are not always enough. If you'd like to block every browser on your computer from accessing a specific website, especially if there are people in the house who will be trying to bypass the control, you'll need to edit one of the files your computer uses to determine how to connect online, or change your router settings. This can get a little technical, but all you need to be able to do is follow instructions.

Steps

Blocking Sites on a Windows Computer

  1. Open Notepad as an administrator. Find your Notepad program, using the search bar if necessary. Right click it and select Run as administrator. You will need to enter an administrator password in order to block sites for the entire computer.
  2. Open your computer's hosts file. You can use this file to tell your computer that a website is actually a device connecting to your computer, preventing it from working as usual. Click FileOpen in Notepad, then find and open the hosts file at ComputerC:WindowsSystem32driversetchosts.[1]
    • If you can't find "Windows," look for "WINNT," "WINNT35," or "WTSRV" instead.
    • If you found the "etc" folder, but don't see a "hosts" file, click Show all files at the bottom right of the Notepad "open file" screen.
  3. Copy the information to a backup document. If you accidentally delete or alter an important line in this document, your computer could fail to load any web pages. Create a backup Notepad file on your desktop or another obvious location, copy-paste the entire contents of the "hosts" document into it, and save it as "hosts file backup" or a similar name.
    • If you accidentally alter the wrong part of the hosts file and something goes wrong, just copy the information back from your hosts backup, and paste it back into the actual hosts document, replacing all the old text.
  4. Return to the original file and fine the "localhost" line. Close your backup file, and return to the actual hosts file. Look for the word "localhost." This is usually at the bottom of the document, where something similar to "127.0.0.1 localhost" or "::1 localhost" is written. Click at the end of this line to start typing.
  5. Write the following information to block a website. First, hit "enter" or "return" on your keyboard to start a new line. On this line, type "127.0.0.1" followed by a space, then type the URL of the website you want to block, such as "www.facebook.com".
    • Include the "www." in the website name, but do not include "http://".[1]
  6. Add new websites on separate lines. You can block as many websites as you like. Make sure to put each one on a separate line, using "127.0.0.1" followed by a space before you enter the website URL.
  7. Save the file in the same location. Navigate to FileSave in the Notepad menu, and save the file with the same name. Click OK if any warnings show up, and do not save it to another folder even if prompted to.
    • If you cannot save your file, try Disable-Norton-Protection-Center, Disable-McAfee, or other antivirus protection software, since these could be blocking you. Activate them again after you are finished saving the document.
  8. Restart the browser if necessary. You might need to restart your browser before you notice any changes, or clear your cache in the browser's preferences. However, even if you do neither of these, you should notice that the websites you listed are blocked within a few minutes.

Blocking Sites on Mac OS X

  1. Launch Terminal. Find and open the Terminal using the Spotlight search bar, or find it manually in Applications → Utilities → Terminal.
  2. Make a backup of the hosts file. The Terminal screen should look like a simple white screen with plain text written on it. Type the following into the Terminal window to make a backup of the file you will be altering:[2]
    • sudo /bin/cp /etc/hosts /etc/hosts-original
    • Press enter or return on your keyboard to submit your command.
  3. Enter your administrator password. You will be prompted to enter an administrator password for your computer. Type this in, then press enter.
    • Your password will not appear while you type. If you typed it in successfully, you will not see any error messages or other notifications.
  4. Open the hosts file. Type in sudo nano /etc/hosts and press enter. The Terminal window should now have a black bar at the top, that says something similar to "File: /etc/hosts". A list of numbers with the word "localhost" next to it should show up.
  5. Add your list of blocked websites. Use the down arrow on your keyboard to move your cursor (the grey square) to the last line of the document. Type in 127.0.0.1 followed by a space, then the name of the website you wish to block. Include the "www." in the website name, but not the "http://".[2] Add as many websites as you like, each on their separate line beginning with 127.0.0.1 and a space.
    • Be careful not to alter anything else in the document. If you accidentally delete or change something, press control X to quit without saving your changes, then start this method again.
  6. Save and quit the file. Press control O, then enter to save your changes. Press control X to close the file, returning to the ordinary Terminal window.
  7. Test your changes. You may find that the sites you listed are already blocked. If you can still access them, make one of the following changes to force the block list to take effect:
    • In the ordinary Terminal window, type sudo dscacheutil -flushcache and press enter.[2]
    • Or restart your computer.
  8. Restore the backup if problems occur. If you cannot connect to any websites, or you encounter other strange problems after this change, restore the original hosts file using the "hosts-original" copy you made. Open Terminal and follow these commands, typing in your administrator password again if prompted:
    • Type sudo nano /etc/hosts-original and press enter to open the backup file.
    • Press control O to save the file.
    • Delete the -original at the end of the file name, so the file name now ends in hosts. Press enter to save the file.
    • Press Y to confirm that you will replace the hosts file you altered.
    • Press Ctrl X to close the file. If you don't notice any changes, type sudo dscacheutil -flushcache and press enter.

Blocking Sites Through Your Router

  1. Use this method for more precise control. Internet routers typically have more precise controls available. For instance, you may be able to block websites at certain times of day, or on certain days of the week. This is also a convenient method if you would like to block a website for multiple devices at the same time.
  2. Access your router. If you have the instructions or manual that came with your router, consult it for specific instructions. Otherwise, try entering each of the following into your browser's address bar, since most common brands use one of these addresses:[3]
    • http://192.168.1.1
    • http://192.168.0.1
    • http://192.168.1.2
    • http://192.168.10.1
    • http://10.0.1.1
  3. Log in to your router. If no one has changed your router's username and password information, it is most likely using one of the default passwords. Search for the brand name of your router on a site like routerpasswords.com, or do a general google search for that brand name and "default password."
    • The most common default username is "admin" and the most common default password is "password".
  4. Change your router settings. Once your are logged in, many router options should be available to change. Each router brand is somewhat different, but website blocking options are usually found under "Access Restrictions," "Content Filtering," "Parental Controls," or a similar phrase.[4]



Tips

  • If these methods are too technical for you, download software such as OpenDNS or K9 Protection and use them to block websites. Look for the "content filtering" or "parental control" options.

Related Articles

Sources and Citations