Website blocking via Hosts file


Recommended Posts

I am trying to block a website through the Hosts file, but the site still loads, despite being supposedly redirected to 127.0.0.1. What I have done is put 127.0.0.1 domain name in the hosts file and saved it, I have verified that it is saved, but when I go to the website, it still loads, even after reboot. Am I missing something or doing something wrong? Or is it windows?

Link to comment
Share on other sites

11 minutes ago, jnelsoninjax said:

I am trying to block a website through the Hosts file, but the site still loads, despite being supposedly redirected to 127.0.0.1. What I have done is put 127.0.0.1 domain name in the hosts file and saved it, I have verified that it is saved, but when I go to the website, it still loads, even after reboot. Am I missing something or doing something wrong? Or is it windows?

You need to ipconfig /flushdns

make sure your hosts file hasn't been saved as hosts.txt by mistake as well

  • Thanks 1
Link to comment
Share on other sites

Who does this anymore?  Run pihole if your looking to block ###### ;)  Or block it on your dns directly with a host override?

 

Do a simple ping does it come back as 127.0.0.1?

 

Also if your browser is using a proxy, doesn't matter what you put in your host file since proxy is what resolves, not the local client.

 

But to your use of host file... Here how to test your setting is working... Keep in mind that hosts file will need admin rights to manipulate... Its also possible your running some antivirus software that prevents manipulation of the hosts file.. And yeah sagum is right, many users will save it has hosts.txt which never used.

 

 

 

 

hostfile.png

Link to comment
Share on other sites

Hello,

You need to make sure that you have entered the fully-qualified domain name (FQDN) into the hosts file.  For example, if you wanted to block https://www.example.com/ you would want to enter the following lines into the hosts file:

 

127.0.0.1 example.com
127.0.0.1 www.example.com

Note that you do not enter the protocol handler (https, http, ftp, et cetera), just the applicable hostnames.

 

Regards,

 

Aryeh Goretsky

Link to comment
Share on other sites

On 4/25/2019 at 11:37 PM, goretsky said:

Hello,

You need to make sure that you have entered the fully-qualified domain name (FQDN) into the hosts file.  For example, if you wanted to block https://www.example.com/ you would want to enter the following lines into the hosts file:

 


127.0.0.1 example.com
127.0.0.1 www.example.com

Note that you do not enter the protocol handler (https, http, ftp, et cetera), just the applicable hostnames.

 

Regards,

 

Aryeh Goretsky

Thanks, I figured it out, and successfully blocked a site as a test using 0.0.0.0 instead of the 127.0.0.1

Link to comment
Share on other sites

14 minutes ago, freqnasty said:

Did you work out why the website was still resolving when you had set it to localhost?

Never did figure that out, but I did not spend allot of time messing with it.

Link to comment
Share on other sites

There are a bajillion things that could of been reason.

 

Didn't put entries in file correctly

saved the file with ext like .txt

didn't put in the actual fqdn of what the client was using for whatever site trying to block

didn't flush the clients local cache, or even the browsers cache - both of which are different caches

browser was using a proxy (dns and or even local host file not used then)

etc. etc. etc..

Link to comment
Share on other sites

38 minutes ago, BudMan said:

There are a bajillion things that could of been reason.

 

Didn't put entries in file correctly

saved the file with ext like .txt

didn't put in the actual fqdn of what the client was using for whatever site trying to block

didn't flush the clients local cache, or even the browsers cache - both of which are different caches

browser was using a proxy (dns and or even local host file not used then)

etc. etc. etc..

I agree, that is why I did not spend any time to try and figure out the reason it did not work, and it was only for a test purpose anyway, I was not using it for a permanent solution.  

Link to comment
Share on other sites

  • 2 months later...
On 4/26/2019 at 9:07 AM, goretsky said:

Hello,

You need to make sure that you have entered the fully-qualified domain name (FQDN) into the hosts file.  For example, if you wanted to block https://www.example.com/ you would want to enter the following lines into the hosts file:

 


127.0.0.1 example.com
127.0.0.1 www.example.com

Note that you do not enter the protocol handler (https, http, ftp, et cetera), just the applicable hostnames.

 

Regards,

 

Aryeh Goretsky

Thanks for this. It helped me out in more ways than I can share. :)

Link to comment
Share on other sites

This topic is now closed to further replies.
  • Recently Browsing   0 members

    • No registered users viewing this page.