This article was co-authored by wikiHow staff writer, Nicole Levine, MFA. Nicole Levine is a Technology Writer and Editor for wikiHow. She has more than 20 years of experience creating technical documentation and leading support teams at major web hosting and software companies. Nicole also holds an MFA in Creative Writing from Portland State University and teaches composition, fiction-writing, and zine-making at various institutions.
There are 9 references cited in this article, which can be found at the bottom of the page.
This article has been fact-checked, ensuring the accuracy of any cited facts and confirming the authority of its sources.
This article has been viewed 1,843,098 times.
Learn more...
Do you want to prevent others (or yourself) from visiting a certain website on your computer? While installing a browser extension on Chrome, Edge, Firefox, or Safari might seem like the answer, it'll only block sites in that browser. If you really need to ensure no one can access a website in any web browser, we have you covered! This wikiHow guide will show you how to completely block access to a website on your Windows 10 or 11 computer, as well as on your MacBook or Mac desktop computer. We'll also show you how to block a website using the BlockSite browser extension on your Chromebook and in Firefox.
Blocking a Website on a Computer: At a Glance
To block a website in all web browsers on Windows and Mac, you'll need to add the website to your hosts file. On Windows, you can edit the hosts file (C:\Windows\System32\etc\hosts) as an administrator in Notepad. On a Mac, you'll need to use the Terminal app to edit the hosts file (/etc/hosts) with admin rights.
Steps
-
Open Start . Click the Windows logo in the bottom-left corner of the screen.
- This method will work to block a website in Microsoft Edge, Google Chrome, Firefox, and any other web browser on Windows 10 and Windows 11.
-
Type in notepad. This will search your computer for the Notepad app. Don't click the app just yet.Advertisement
-
Open Notepad as an administrator. Right-click Notepad at the top of the Start window, click Run as administrator in the drop-down menu, and click Yes when prompted. The Notepad window will open.[1]
- If your mouse doesn't have a right-click button, press the right side of the mouse, or use two fingers to click.
- If your computer uses a trackpad instead of a mouse, use two fingers to tap the trackpad or press the bottom-right side of the trackpad.
-
Click the File menu and select Open…. This option is near the top of the File drop-down menu. Doing so opens a File Explorer window.
-
Navigate to the "etc" folder. To do so:
- Click This PC on the left side of the File Explorer window.
- Scroll down and double-click your hard drive's name (usually OS (C:)) in the middle of the window.
- Double-click the Windows folder.
- Scroll down and double-click the System32 folder.
- Scroll down and double-click the drivers folder.
- Double-click the etc folder.
-
Click the "Text Documents" box. Click the box that says Text Documents (*.txt) in the lower-right side of the window. A drop-down menu will appear.
-
Select All Files. You should now see several files appear in the main window.
-
Remove security from the "hosts" file. This will allow you to make changes to the hosts file, which is where you can add a list of websites to block. To do so, follow these steps.
- Right-click the "hosts" file.
- Click Properties in the menu.
- Click the Security tab.
- Click Edit.
- Check the "Full Control" box.
- Click OK, then click Yes when prompted.
- Click OK.
-
Select "hosts" and click Open. The "hosts" file will open in Notepad.[2]
-
Create a new line at the bottom of the document. Click the very end of the last line on the page, then press ↵ Enter.
-
Add websites to the block list. To block a website in all web browsers on your computer, do the following:
- Type 127.0.0.1 and press Tab ↹.
- Type in a website's address without the "www" part (e.g., "facebook.com", "roblox.com").
- Press ↵ Enter to start a new line.
- If you want to block another website, type 127.0.0.1 again, press Tab ↹}, and then enter the next address.
- Repeat for all websites you want to block on this computer.
-
Try blocking alternative versions of the website's address (optional). If you find that certain websites are still accessible after you complete this method, you can also block websites using these options:
- IP address — You can find a website's IP address and then block it in the "hosts" file to prevent people from accessing the website via its IP address.
- Mobile site — By placing "m." in front of a website's address (e.g., "m.facebook.com" instead of "facebook.com"), you can block the mobile version of the website as well.
-
Replace the existing "hosts" file with the edited one. To do so:
- Click File in the top-left corner of Notepad.
- Click Save As... in the drop-down menu.
- Click the "Save as type" drop-down box, then select All Files in the menu.
- Click the "hosts" file in the main window to select it.
- Click Save, then click Yes when prompted.
-
Flush your computer's DNS cache. You'll use Command Prompt to perform this action. Flushing the DNS cache will prevent saved browser information from clashing with your blocked sites.[3]
- Press the Windows key and type "cmd".
- Right-click Command Prompt.
- Click Run as administrator.
- Click Yes to confirm.
- In the Command Prompt, type ipconfig /flushdns.
- Press Enter.
-
Restart all web browsers. If you have any browser windows open, close them and then re-open them. Any websites you added to the "hosts" file should now be blocked in your browsers.
- If the websites still aren't blocked after restarting your browsers, try restarting your computer.
-
Open a Terminal on your Mac. To block a website on your Mac, you'll need to make a change to the hosts file on your computer. The easiest way to do this is to use the Terminal app. To open Terminal, click the Launchpad (the multicolored squares) on your Dock, type terminal, and click Terminal.[4]
-
Open the "hosts" file. Type in sudo nano /etc/hosts and then press ⏎ Return.[5]
-
Enter your password. Type in the password that you use to log into your Mac, then press ⏎ Return. The "hosts" file will open for editing.
- Terminal won't show your password's letters as you type.
-
Move the blinking cursor down to the bottom of the page. Press the ↓ key until the cursor is at the end of the last line of text on the page, then press ⏎ Return.
-
Add websites to the block list. To block a website in your computer's browsers, do the following:
- Type in 127.0.0.1 and press Tab ↹.
- Type in a website's address without the "www" part (e.g., "facebook.com").
- Press ⏎ Return to start a new line, then repeat the above two steps with other addresses you want to block.
-
Try blocking alternative versions of the website's address. If completing this method doesn't block all parts of the website, you can replace the web addresses you enter with other options, including:
- IP address — You can find a website's IP address and then block it in the "hosts" file to prevent people from accessing the website via its IP address.
- Mobile site — By placing "m." in front of a website's address (e.g., "m.facebook.com" instead of "facebook.com"), you can block the mobile version of the website as well.
-
Save and exit the editor. Once you have entered all of the sites that you want to block, save and exit by pressing Control+O and then pressing ⏎ Return.[6]
- To exit the hosts file, press Control+X.
-
Flush your computer's DNS cache. Type in sudo killall -HUP mDNSResponder && echo macOS DNS Cache Reset and press ⏎ Return. This command will flush your Mac's DNS cache, which will ensure that all of the website's previous data (e.g., saved passwords) is erased. Your listed site should now be blocked in all browsers on your computer.[7]
- If your computer's browsers don't block the site, restart your computer to finalize the changes.
-
Open the BlockSite page on the web store. To block a website on your Chromebook, you'll need to use a Chrome extension like BlockSite. BlockSite allows you to block individual pages or entire websites.
- The basic option to block a website in BlockSite is free, but you'll need to pay for added features, such as the ability to password-protect the blocklist.
- For a fully free alternative to BlockSite, try StayFocusd. Our guide to blocking a website with StayFocused will walk you through the process.
- You can also use this method in the Chrome web browser on a PC or Mac, although it will only apply to Google Chrome. If you want to make sure the website is blocked in all browsers on the computer, jump to the steps for editing the hosts file on a PC or Mac.
>
-
Click Add to Chrome. It's a blue button on the upper-right side of the page.
-
Click Add extension when prompted. This installs BlockSite on your Chromebook.
- After installing BlockSite, you'll be prompted to accept the terms. You'll also be prompted to upgrade to a paid version. If you don't want to upgrade, click Skip to limited version when prompted.
- BlockSite will prompt you to block certain websites at first. If you don't see the website you want to block in the list, just skip this prompt. You'll be able to block 3 websites in BlockSite in a few moments.
-
Click the Block Site icon. It's a shield-shaped option in the upper-right side of the Chrome page. A drop-down menu will appear.[8]
- If you don't see this icon, click the puzzle piece at the top-right corner of Chrome, then click the pushpin icon next to BlockSite to pin it to your toolbar.
-
Click the gear icon. This opens BlockSite's settings panel, where you can add websites to your block list.[9]
- You can also click the gear-shaped icon in the top-right corner of the drop-down menu if you want to open the BlockSite page.
-
Click + Add to block list. A field will open, allowing you to enter the URL of the website you want to block.[10]
-
Enter a website's address. For example, if you want to block YouTube, enter youtube.com.
- If you want to block a specific page on a website, go to that page, then copy the address by clicking the address bar at the top of the window and then pressing Ctrl+C. Then, you can right-click the field and select Paste to paste it in.
>
-
Click +. It's to the right of the website text field. Your website will immediately be added to Block Site's list of blocked websites.[11]
- You can add 2 more sites to your block list for free if you'd like.
- When you're finished adding websites to your block list, click Done to continue.
- You can remove your site from BlockSite's blocklist at any time by clicking the red circle next to the address.
-
Set up password protection (optional). To prevent users from being able to edit the list of blocked websites, you can add a password to your block list. However, you'll need to upgrade to the full (paid) version of BlockSite to do so. If you'd like to proceed, click Password Protection in the left panel, and follow the on-screen instructions to subscribe.
-
Allow BlockSite in Incognito mode. One way that people can use to get around BlockSite's restrictions is by using incognito mode, but you can enable BlockSite in incognito to fix this problem:
- Click the menu ⋮ at the top-right corner of the window.
- Go to Extensions > Manage Extensions.
- Click Details below the "BlockSite" heading.
- Toggle on "Allow in incognito".
-
Go to the BlockSite page on the Firefox Add-ons Store. If you only want to block websites in Firefox, you can use a free browser extension like BlockSite. Unlike in Chrome and other browsers, the full version of BlockSite for Firefox is totally free, including the ability to password-protect your block list and block up to 6 websites.
-
Click + Add to Firefox. After a moment, a pop-up windows will appear.
-
Click Add when prompted. This is also at the top of the window. Doing so will install Block Site in your Firefox browser.
-
Check the box next to "Pin extension to toolbar" and click OK. This ensures you can easily access BlockSite when needed.
-
Click the BlockSite app icon. It's a red shield-shaped icon on the toolbar.[12]
- The first time you open the extension, you'll need to click Agree to agree to BlockSite's terms.
-
Click the gear icon. This opens your BlockSite settings page.
-
Enter a website's address into the bar at the top of the page. For example, if you want to block Roblox, you'd type roblox.com.[13]
- If you want to block a specific page on a website, go to that page, then copy the address by clicking the address bar at the top of the window and then pressing Ctrl+C (Windows) or ⌘ Command+C (Mac).
-
Click +. It's to the right of the website text field. Your website will immediately be added to Block Site's list of blocked websites.
- You can remove your site from Block Site's blocklist at any time by clicking the red circle icon to the right of the website's URL in the list of blocked sites.
-
Click Password Protection. To require a password to access your BlockSite settings, you can set up a password.
-
Select a password-protection option. For added protection, you can prevent others from editing your BlockSite settings and/or allow users to enter a password to access a blocked website.
- If you want to be able to enter a password to access a blocked website, check the box next to "Require password to access blocked sites."
- If you want to prevent users from making changes to your blocklist or settings, check the box next to "Protect your BlockSite Options and the Chrome Extension page with password." Even though it says "Chrome," this option will generally work to protect your block list. However, in our testing, we weren't able to make it prevent the extension from being uninstalled.
- After choosing either option, enter your email address and create a password.
- Then, open the email from BlockSite and click the Verify now button to confirm.
- Now, you'll need to enter your password before you can add or remove sites.
Community Q&A
-
QuestionHow can I open a file on Windows 7 if I received an "Access is Denied" message?
Community AnswerFind notepad.exe in your windows\system32 folder, and choose "Run as Administrator." Then, go to file, open and navigate to the hosts file, and remember to change the bottom file type from *.txt to All files. -
QuestionWhy did it say that I don't have permission to save?
Community AnswerThis may happen when a user might not be authorized to save or modify certain system files in Windows OS platform. To change this, locate the file that you wish to modify. Right-click on the file and select Properties. This opens a pop-up window with tools to tweak the file. Next, go to the Security tab and highlight the User/User name (aka User Account name) and its permission is displayed in the box below it. To allow permission, click on the Edit button and on the new pop-up window, highlight the User again and tick the items below to provide necessary permissions. -
QuestionI tried saving, but it refuses to save. What should I do?
Community AnswerOpen Notepad as an administrator. Open Notepad >> in Notepad: click on file>>open file>>save.
Video
Tips
-
If your computer has a separate account for a child, you can use parental controls to monitor and restrict their browsing.Thanks
Tips from our Readers
- When editing the host file, it's better to put 0.0.0.0 instead of 127.0.0.1. That way, you don't have to deal with the localhost timeout, which can sometimes be a couple seconds. With 0.0.0.0, it will instantly tell you that a site can't load.
Warnings
- Blocking websites with the "hosts" file is a good way to prevent any browsers from opening them, but people can still get around the block using a VPN or mobile data on their phones.Thanks
References
- ↑ https://www.tenforums.com/tutorials/141019-block-websites-using-hosts-file-windows.html
- ↑ https://www.tenforums.com/tutorials/141019-block-websites-using-hosts-file-windows.html
- ↑ https://techcommunity.microsoft.com/discussions/windows11/how-to-clear-computer-cache-on-windows-11/4482728/replies/4482764
- ↑ https://support.apple.com/guide/terminal/open-or-quit-terminal-apd5265185d-f365-44cb-8b09-71a064a42125/mac
- ↑ https://osxdaily.com/2007/03/19/block-access-to-specified-sites-by-modifying-etchosts/
- ↑ https://docs.icer.msu.edu/Editing_Text_with_Nano/
- ↑ https://www.civicplus.help/municipal-websites-central/docs/clear-local-dns-cache-on-windows-mac
- ↑ https://blocksite.co/blog/digital-mindfulness/how-to-block-a-website
- ↑ https://blocksite.co/blog/digital-mindfulness/how-to-block-a-website
- ↑ https://blocksite.co/blog/digital-mindfulness/how-to-block-a-website
- ↑ https://blocksite.zendesk.com/hc/en-us/articles/360019467337-How-to-block-websites-on-the-browser-extension
- ↑ https://youtu.be/TLp5N-0hLis?t=272
- ↑ https://blocksite.zendesk.com/hc/en-us/articles/360019467337-How-to-block-websites-on-the-browser-extension
About This Article
1. Run notepad as an administrator.
2. Go to File > Open.
3. Navigate to C:\Windows\System32\drivers\etc.
4. Remove security from the "hosts" file.
5. Open the "hosts" file.
6. Type "127.0.0.1" at the bottom and press Tab.
7. Type the address you want to block.
8. Save the file.













































