Skip to main content

HOW TO BLOCK A WEBSITE USING THE HOSTS FILE ON A PC?

· One min read
Bora

INTRODUCTION

“The computer file hosts is an operating system file that maps hostnames to IP addresses. It is a plain text file” source wikipedia. We are going to use this file to block some websites on a single PC.

Step 1

Open notepad as administrator.

Step 2

Click File > Open and browse to C:\windows\system32\drivers\etc.

Change the file extension from Test Documents (.txt) to All Files (.*) to see the hosts file and open it.

Step 3

Under 127.0.0.1 localhost enter ‘127.0.0.1 youtube.com’ as on the screenshot. You can add # before the command which disables this blocking. We simply redirect this domain name to our local ip this creates a loop. When we try to reach blocked website in the hosts file our browser tries to reach the ip address 127.0.0.1 which is our local ip address. There is no http server running on our PC then we can’t open web page. Save the file.