Sometimes you need to block some specific websites from your Office or Home PC. For many reasons, you have to do that. For parental control, you have to do that for blocking adult content from your child PC or for controlling the office PC and confirm that no one using social media or any of the related websites in office. And you can also block some app websites to block the update system of the app or verification of purchase. Now,
How can you block a website from your windows?
Let's see, First, you can do it via the hosts file. A hosts file is a complex document of the internet rules on your PC. It contains the mappings of IP addresses to hostnames, you can totally block all kind of network connection in your computer but now we see how to block a website through it. Now I'm Showing you how do you do that.
Method - 1
- Open Notepad on your computer with administrator access. The animation picture of above is an example of it.
- Through the notepad software, click File > Open and go to C:\Windows\System32\drivers\etc\ in bellow select All Files and the hosts file appear then open it.
- The last two lines of your hosts file should read "# 127.0.0.1 localhost" and "# ::1 localhost".
- At the end of the file, you can add the addresses of websites to block. To block Google, for example, add "127.0.0.1 www.google.com" to the end of the file without the quote marks. You can block as many sites as you want this way, but remember you can only add one per line.
- Repeat this step until you've added all the websites you want to block.
- Now close the hosts file and click Save. Reboot your computer for the changes to take effect and you'll find that all those websites are now blocked.
Method - 2
Now I'm providing you a shortcut of the above work in a programing file(.cmd). This file will help you to add all the lines in your host file and it helps you to block the website in one click. But to unblock the website you have to remove the line from the hosts file using the Method-1.
All the details is up on the picture and now you can download the file from bellow. You don't need to be expert for editing the file. Just simple logic you have to understand with the help of the above picture or simply you can use Method 1.
Download the file and Right-click on the file and click Edit on the command box.
How to Block Any Website On Your Mac
- Make sure you have administrator access to your Mac. Now open Terminal. You can find it under /Applications/Utilities/Terminal.
- Type Sudo nano /etc/hosts and press enter. Enter the user (login) password when prompted.
- This will open the file /etc/hosts in a text editor. Type the name of the website in a new line in this format "127.0.0.1 www.blockedwebsite.com" (minus the quotes). For each website you want to block, start a new line and type the same command with only the name of the website being replaced. When done, press ctrl+x and then Y to save changes.
- Now key in the command sudo dscacheutil -flushcache and press Enter or restart your machine to make sure the websites are blocked.