In this post we will see how you can block a website, in Microsoft Windows, macOS and Linux.

It can be for activating a program or for blocking malware or even blocking adult websites in collages. It is helpful in many cases. Soon I will be making a software for this on different platforms so you can apply this method easily. But for now I will show you how to do it manually, It doesn’t require any programming skills but you need some computing experience according to your Operating System. So, with that being said let’s start our first step of blocking a website.

Locating Host File

If you want to know what is a DNS and how it works, then just click on the link. So now, that you know what is a DNS, the Host file is the file that remaps the default DNS, I mean overwriting your’s in place of the default one. So, now we have to find out where is your host file located according to your OS. Below is a list of paths of host file in different operating systems, you can simply copy and paste them in your file managers.

Microsoft Windows

Note that I have tested this location from Windows 7 to Windows 10 Anniversary Update, So if you are using Windows XP or below that make sure you Google once and then find the file.


Note that the / means the root directory of your file system not the home folder. Also ,I could not test the location exactly because I don’t have a mac, so please check and put the exact location in the comments below!


It should be almost same as macOS, but I have tested this location for Zorin OS (Ubuntu Derivative).

Editing Hosts File

So, now will see how you can edit the hosts file. For an example ,I have taken a screenshot of my hosts file. Note that the entry is added by me. You can the websites you want to block here. Below is the screenshot of hosts file in Windows 10 Anniversary Update. I have used Sublime Text 3 Here!

[Image Not Found]

Now, you can observe that before every line there is a hash or “#” symbol. It shows that the link is commented. So if you want to add a comment just add a hash symbol and write your comment. For example:

# This is a hosts file comment. Edit Me.

You can leave a blank link if you want, but that is unnecessary for this tutorial. So, now the main point creating a entry in hosts file. To Create a entry in hosts file , simply type in and then give a space and type the website domain you want to block. Here is an example to block

Now make sure that you are not including the whole URL of the website, It just needs the domain name and you need to exactly enter that, neither “WWW” not the protocol (HTTP).

Saving The Hosts File

Now, If you have come till this point, then you have crossed the hurdle. While saving the file make sure that you are saving the file in the same location, same file name. After the saving is completed, let’s get to the next step.


Now, we have saved the file and to reload it or to let the OS know that we have changed the file, simply reboot your computer and you should be good to go.