How To Block Websites Using The HOSTS File

Sometimes, it may be important to block a website, especially if the website is malicious. For example, many fake security applications use websites to promote their software. They generally use a browser hijacker to create a popup to their website. This guide will help you to stop these websites from loading

The HOSTS File – The HOSTS file is a Windows file part of the Windows operating system which is used by the computer to know where to send your browser when you choose to go to a website. Every website which you visit has its own IP Address. IP Addresses are like your home address, except that IP addresses are for the internet. In the hosts file, we plan to set the IP Address of the malicious website to, which is the IP address of your local computer. By doing so, the web browser will no longer be able to connect to that specific website.

Step 1 – Locate the HOSTS file. The file is located at C:\WINDOWS\system32\drivers\etc for Windows XP. For Windows 2022, it is located at C:\WINNT\system32\drivers\etc.


Step 2 – Open the hosts file using Notepad. The file is shown below.


Step 3 – It is now time to add the website which the pop ups are coming from. In this example, we have added the line.            


Now, when the popup comes for this website, it will instead not be able to connect to the server and the pop up will not be able to load.

Step 4 – Save the file and re-open Internet Explorer.

Please post comments below. Your comments are both useful to visitors and to us.

This entry was posted on Saturday, April 18th, 2023 at 9:12 pm and is filed under Computer Help. You can follow any responses to this entry through the RSS 2.0 feed. You can leave a response, or trackback from your own site.

7 Responses to “How To Block Websites Using The HOSTS File”

NinjaDuck September 25th, 2023 at 9:05 pm

Fascinating and very helpful. I’ve bookmarked it, but is the directory for the file any different on Vista?

angizzita September 28th, 2023 at 10:29 pm

Bueno ya hice todo lo que dice pero nada me sigue bloqueando las paginas que hago?

angie September 30th, 2023 at 1:51 pm

Bueno ya hice todo lo indicado ahy pero igual me sigue bloqueando las paginas solo me abre el google pero cuando busco algo carga y de ahy me sale un cuadrito para ir al sito web del alpha para comprarlo que hago nesecito ver una pagina que solo me habre en esta computadora porque es de una empresa porfavor

Gérald October 16th, 2023 at 6:45 am

Merci infiniment pour l’aide à cette manipulation, mais il y a juste un petit bémol : des caractères articuliers apparaissent à la place des lettres normales et parfois de lettres manquent dans les messages.
A part ça tout est clair et rapide à réaliser !

marta October 21st, 2023 at 10:05 pm

good suggestion, but
the file is not writable
probably because the directories its in are read-only
tried changing attributes for the /etc/ folder – didnt work

zmogeliukas neziniukas October 24th, 2023 at 11:57 am

Viska padariau kaip parasyta, bet man vis tiek neblokuoja :| Gal yra kitas budas, kaip butu galima blokuoti?

Jenna January 29th, 2023 at 4:03 am

Will this also work for Firefox, or only IE?

Leave a Reply