• 0

Website blocking via Hosts file


Question

+jnelsoninjax

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 post
Share on other sites

10 answers to this question

Recommended Posts

  • 0
sagum
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 post
Share on other sites
  • 0
+BudMan

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

  • Like 1
Link to post
Share on other sites
  • 0
Robert_Leo1

If you are trying to block website through host files then make sure that your host's files haven't been saved with wrong names.

Link to post
Share on other sites
  • 0
goretsky

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

  • Like 1
Link to post
Share on other sites
  • 0
+jnelsoninjax
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 post
Share on other sites
  • 0
freqnasty

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

Link to post
Share on other sites
  • 0
+jnelsoninjax
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 post
Share on other sites
  • 1
+BudMan

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 post
Share on other sites
  • 0
+jnelsoninjax
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 post
Share on other sites
  • 0
Robert_Leo1
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 post
Share on other sites
This topic is now closed to further replies.
  • Recently Browsing   0 members

    No registered users viewing this page.