How do you block websites using the hosts file?

The world of internet is a pool of numerous websites which has turned everything digital. But not all those website might be appropriate for everyone.Suppose that you want to stop your friends or children from opening a particular website on your computer. Just telling them to stop opening them wouldn’t be a great solution. If you feel that you need to block certain sites manually be changing certain settings on your system, here you go. This article is going to navigate you perfectly through the steps you need to follow in order to accomplish it.


ADVERTISEMENT


But before we proceed, let me introduce you to a new term Windows Host File. The hostnames connected to a network needs to be mapped to their corresponding IP addresses. This is done so to uniquely identify a particular system in a pool of systems connected to the Internet. This Windows Host file is responsible for providing this mapping function. Slight modifications made to this file can help you block the particular website. Well, now let us start discussing the process.

Also read: –

  • How to Block all websites and allow only one website in your PC
  • How to restrict PC usage time for an account

STEPS TO BLOCK WEBSITES BY MODIFYING WINDOWS HOST FILE

Step 1 – Open your file explorer and copy and paste the given path below to address bar and go to etc folder.

 


ADVERTISEMENT


C:\Windows\System32\drivers\etc

How do you block websites using the hosts file?

 

Step 2 – 

Now, Right click and copy the hosts file and paste it somewhere else on your computer. Lets copy and paste it on desktop.

How do you block websites using the hosts file?

 

Step 3 – Go to desktop where you have pasted the file and right click and click on open with.

How do you block websites using the hosts file?

 

Step 4 – Now, choose notepad as the option to open the file with notepad.

How do you block websites using the hosts file?

Step 5 – Once the file opens up, just scroll down and copy and paste these two lines at the bottom. Just make sure to change the websitename with the name of the file which you want to block.

127.0.0.1      www.websitename.com

127.0.0.1      websitename.com

For example if you want to block facebook, just put the code as shown below.

How do you block websites using the hosts file?

STEP 6

Now, save the changes to the file.

After that, copy and paste this newly created file back again in the etc folder. The original file will get replaced.

How do you block websites using the hosts file?

 

STEP 7

 

How do you block websites using the hosts file?

How to redirect Blocked website to another website

Now suppose that you need to make any other website open up when your friends secretly try to open up the site you had opposed. Lets see how it can be done.

  • Open up the command prompt and type ping sitename.com. The sitename is the name of the site to which you want the website to be redirected on. Say for example you need to redirect to google.com, you can type ping google.com. This will give you the IP address of the site.

How do you block websites using the hosts file?


ADVERTISEMENT


 

As shown above,I have obtained the address for google.com.

  • Now, as described above, instead of adding 127.0.0.1 to the bottom of notepad, you can add

IPaddress websitename.com

IPaddress is the address you have currently received from command prompt and website name is the name of the site you want to redirect to another site.

How do you block websites using the hosts file?

 

In my case, I am redirecting the site hello.com to the Google’s site which has the IP address 216.58.220.40. From now on the Google’s site opens up when you search for hello.com.

6. Once you’ve added all the sites you wish to block to the hosts file, click File > Save, and close Notepad.

How do you block websites using the hosts file?

How to block websites on Mac


1. Ensure that you are logged in as an administrator, and open Terminal (Launchpad > Terminal).

How do you block websites using the hosts file?

2. In Terminal, type “sudo nano /etc/hosts” and press enter.

How do you block websites using the hosts file?

3. Type in your password and press enter.

How do you block websites using the hosts file?

4. The hosts file will open. It will look like this:

How do you block websites using the hosts file?

5. To block access to a website, you will need to append a line to the bottom of the hosts file. For example, if you want to block www.google.com, you would add

How do you block websites using the hosts file?
. You will need to use the downward-facing arrow key on your keyboard to move the cursor to the bottom of the hosts file.

How do you block websites using the hosts file?

6. The numbers in front of the URL will always be

How do you block websites using the hosts file?
. All you need to change is the URL that you wish to block. For example, here we’ve blocked access to Google, YouTube, and Facebook:

How do you block websites using the hosts file?

7. Once you’ve added all the sites you wish to block to the hosts file, press control + O on your keyboard, then enter to save the changes to the hosts file, and then control + X. After you’ve done that, close Terminal.

How do you block websites using the hosts file?

The best way to manage children’s digital wellbeing


If you’re looking for the perfect tool to ensure the little ones can surf the web safely, you definitely need to check out Trend Micro Family for Kids. The real-time image filtering application contains built-in features to ensure children remain safe online. Leveraging AI technology, the free extension for Google Chrome and Microsoft Edge is a truly indispensable safeguard.

The app automatically filters explicit graphics relating to:

  • Pornography
  • Alcohol and drugs
  • Gambling
  • Racism
  • Violence, and lots more

Also use Trend Micro Family for Parents to set content restrictions, understand your child’s digital footprint, and ward off potential cyber threats. Click on the button below to give it a try:

How do I block websites with hosts?

Troubleshooting & FAQ.
Go to the hosts file: Enter %SystemRoot%\System32\drivers\etc\ in the address bar of the file explorer or enter that string as a Run command..
Right-click on it and click on Properties..
At the bottom of this screen you will see Attributes. ... .
Click on Apply and OK to save your changes..

How do I block a website on Windows 10 host file?

Editing The HOSTS File Manually Anytime you see a # symbol, that line is ignored when the HOSTS is loaded. In other words, everything after # sign doesn't exist. To block a website, add 0.0. 0.0, followed by the root domain.

How do you block all websites except one using hosts file?

Can you block all websites except one in router?.
Access your router's settings by logging in..
Find the parental controls, web filtering or similar settings. ... .
There should be two filtering types: the blacklist and the whitelist. ... .
Add specific websites or URLs to the whitelist one by one..
Save your settings..

How do I block a website with chrome host?

How to Block a Site by Editing the Hosts File.
Head to File → Save or press CTRL+S to save. Don't save it as a . txt file since it won't work..
Open Chrome and type the domain name you blocked to see if it works..
Repeat the process by adding new lines whenever you want to block a new website..