This wikiHow teaches you how to make certain websites inaccessible through the browser on a Windows or Mac computer by editing the hosts file (“hosts”). In addition, you can also block sites on your iPhone or iPad via the “Restrictions” menu in the device settings. For Android device users, you can use the free BlockSite app to restrict access to certain websites and apps.
Step
Method 1 of 4: Via Windows Computer
Step 1. Open the Start menu
Click the Windows logo that appears in the lower-right corner of the screen or press Win.
In Windows 8, you need to hover over the top right corner of the screen and click the magnifying glass icon
Step 2. Type Notepad into the Start window
After that, the Notepad program will appear at the top of the Start menu window.
Step 3. Right click Notepad and select Run as administrator.
With this option, Notepad will be opened using administrator rights. If the program is not running in administrator mode, you cannot edit the hosts file.
On laptops with a trackpad instead of a regular mouse, touch the trackpad with two fingers to replace the right-click mechanism
Step 4. Click Yes when prompted
The selection will be confirmed and the Notepad program will be opened.
Step 5. Click File and select Open….
Option " Open " is in the drop-down menu " File ”.
Step 6. Visit the hosts file folder (“hosts”)
In the window that appears after you click on the option “ Open… ”, follow these steps:
- Click the tab " This PC ” on the left side of the window.
- Double-click the computer's hard drive (eg. OS (C:) ”).
- Double click the folder " Windows ”.
- Scroll down and double click the folder” System32 ”.
- Scroll down and double click the folder” drivers ”.
- Double click the folder " etc ”.
Step 7. View all file types
Click the “Text Documents” drop-down box at the bottom of the window, then click the “ All Files ” in the drop-down menu. You can see several files displayed in the window.
Step 8. Allow editing of the hosts file
Right-click the hosts file, and then follow these steps:
- Click " Properties ”.
- Click " Security ”.
- Click " Edit ”.
- Check the "Full Control" box.
- Click " OK " and select " Yes ' when prompted.
- Click " OK ” to exit the “Properties” window.
Step 9. Double click the " hosts " file
The file will open in the Notepad program so you can view and edit its contents.
Step 10. Swipe to the bottom of the file
You should see two lines of " localhost " text at the bottom of the page.
Step 11. Click the bottom of the last line of text
The bottom of the page has the line "::1 localhost " or " 127.0.0.1 localhost ". The mouse cursor should be just below the last line of text on the file page.
Be careful not to delete anything already stored in the hosts file
Step 12. Type in 127.0.0.1 and press Tab key
The address is a loopback address to your own computer that will display an error page in the web browser when someone tries to visit a blocked website.
Step 13. Type in the address of the site you want to block
For example, to block Google, type www.google.com.
If you want to block a site on Google Chrome, you need to place a space and enter the "www.[site].com" version of the website address after the "[site].com" version. For example, to block Facebook, type 127.0.0.1 facebook.com www.facebook.com
Step 14. Press Enter key
The cursor will move to a new line. The code entered will tell the computer to redirect the website to the reversal address.
- You can add as many sites as you want to block (one site per line) using the same number as before (127.0.0.1).
- If you want to block completely, enter a different variation of the address (eg "google.com" and "https://www.google.com/").
Step 15. Save the hosts file
Changes will not be saved if you only save via the “ File ” > “ Save " Therefore, follow these steps to confirm the changes:
- Click " File ”
- Click " Save As… ”.
- Click " Text Documents " and select " All Files ” in the drop-down menu.
- Click the " hosts " file.
- Click " Save ”.
- Click " Yes ' when prompted.
Method 2 of 4: Via Mac Computer
Step 1. Open Spotlight
Click the magnifying glass icon that appears in the upper-right corner of your Mac's screen.
Step 2. Type terminal into the Spotlight window
After that, the Terminal option will be displayed at the top of the search results.
Step 3. Double-click the Terminal program icon
Step 4. Open the computer's hosts file (“Hosts”)
Type the following code into the Terminal window and press Return:
sudo nano /etc/hosts
Step 5. Enter the Mac computer password when prompted
Type in the password you use to log into your computer, then press Return.
The terminal will not display the password characters when you type the entry
Step 6. Move the blinking cursor to the bottom of the page
Press the key until the cursor is under the last line of text displayed on the page.
Step 7. Enter the local host address
Type 127.0.0.1 in a blank line. This address is a loopback address to your own computer.
Step 8. Press the Tab key
Once pressed, the cursor will move to the right.
Do not press the Return key at this stage
Step 9. Type in the address of the site you want to block
For example, if you want to block Google, type in www.google.com.
- The line you entered should look like this: 127.0.0.1 www.google.com.
- If you want to block completely, enter different address variations (eg "google.com" and "https://www.google.com/").
- If you want to block the site in question on Google Chrome, place a space and add the "www.[site].com" version of the desired website address after the "[site].com" version. For example, to block Facebook, type 127.0.0.1 facebook.com www.facebook.com.
Step 10. Press the Return key
With this command, the computer will redirect the blocked website to the reversing address.
You can add as many websites as you want to block (one address per line) using the same number as before (127.0.0.1)
Step 11. Press the key combination Control+X
With this command, the hosts file will be closed in the text editor window. You will be prompted to save changes afterwards.
Step 12. Press Y to save changes
After that, the computer will ask for the name of the file you want to use. Since you will be overwriting the original hosts file, you do not need to rename the file.
Step 13. Press Return
Changes will be saved to the original hosts file. The text editor window will close and you will be taken back to the main Terminal window. Now the added website cannot be accessed through any web browser on the computer.
Method 3 of 4: Via iPhone
Step 1. Open the device settings menu (“Settings”)
This menu is indicated by a gray gear icon. Usually, you can find this menu icon on your device's home screen.
Step 2. Swipe the screen and touch General
It's at the bottom of the screen (iPhone) or the top-left corner of the screen (iPad).
Step 3. Scroll down and select Restrictions
It's in the middle of the “General” page.
Step 4. Enter the restriction code
This code is the passcode used to enable restrictions on the iPhone or iPad.
If restrictions have not been activated, touch the option “ Enable Restrictions ” first, then enter the desired passcode twice.
Step 5. Scroll down and tap Websites
This option is the last entry under the " ALLOWED CONTENT " heading.
Step 6. Select Limit Adult Content
You'll see a blue tick to the right of this option once it's selected.
Step 7. Touch Add a Website under the "NEVER ALLOW" heading
This option is the last option displayed on the page.
Step 8. Type in the web address of the site you want to block
Addresses must begin with "www" and end with a domain marker (eg ".com" or ".net"). However, you can omit the "https:" segment if possible.
-
For example, if you want to block Facebook on your iPhone or iPad, type
www.facebook.com
- .
Step 9. Touch the Done button
It's a blue button in the lower-right corner of the keyboard. The selected site is now inaccessible via the Safari browser.
This setting also applies to other popular mobile browsers, such as Chrome and Firefox
Method 4 of 4: Via Android Device
Step 1. Download the BlockSite app
BlockSite is an app that allows you to block websites and apps from being used on Android devices. open
“ Google Play Store ” and follow these steps:
- Touch the search bar.
- Type blocksite and tap the " Search " button.
- Touch the button “ INSTALL ” under the "BlockSite - Block Distracting Apps and Sites" heading.
- Touch the button “ ACCEPT ' when prompted.
Step 2. Open Block Site
Touch the button “ OPEN ” in the Google Play Store window, or tap the Block Site app icon which looks like a shield on the device's page/app drawer.
Step 3. Touch the ENABLE button
It's a green button at the bottom of the screen.
Step 4. Select GOT IT when prompted
The device's “Accessibility” accessibility menu will open in the settings app (“Settings”), but if not, follow the following procedure:
- Open the settings menu (" Settings ”).
- Scroll down and select " Accessibility ”.
Step 5. Enable Block Site in Android device settings
Follow these steps on the “Accessibility” menu:
- Touch " Block Site ”.
-
Touch the gray " BlockSite " switch
Step 6. Reopen Block Site
If the Block Site app is closed or hidden, re-show the app before continuing.
Step 7. Touch the button
It's in the lower-right corner of the screen. After that, you will be taken to the website blocking page.
Step 8. Enter the website address
Tap the text field at the top of the screen, then type in the address of the website you want to block (eg facebook.com).
Step 9. Touch the button
It's in the upper-right corner of the screen. The website will be added to the list of blocked sites in Block Site. After that, you can't visit the site in question via Google Chrome.
You can unblock it at any time by tapping the trash can icon to the right of the site's name
Step 10. Block apps on Android device
If you need to temporarily block an app, touch the “ + ” in the lower right corner of the Block Site screen, select “ APPS ”, and touch the name of the app you want to block.
As with websites, you can unblock an app at any time by tapping the trash icon to the right of its name
Step 11. Block adult content on Android devices if necessary
If you want to prevent children from visiting adult sites or viewing prohibited content, read this article for further instructions on blocking adult content.
Tips
- You need to clear the computer's DNS cache after editing the hosts file to prevent interference/conflict between the hosts file and browser.
- To unblock a site from the hosts file, reopen the file and remove the added site line. Make sure you save changes after deleting the added rows so that the site can be accessed again.
- iPhone restriction settings will apply to both Safari and other browsers.