0

I was able to modify my host file on my Windows 10 laptop by copying it onto my desktop, modifying it and then pasting it back to the system32/drivers/etc folder. I'm doing this to prevent me from going to certain sites. I'm using one of these host files from GitHub:

https://github.com/StevenBlack/hosts

The issue is after I make this change and restart my computer, my computer won't reconnect to the internet. Upon restart my CPU usage will rise and when viewing the task manager this service:

Service Host: DNS Client

is causing the CPU usage to spike to at least 30% but the catch is the task never seems to finish (I waited at least 30-45 min). The host file I pasted in does have a lot of entries (2,000 or so) so wasn't sure if the number of websites you insert can cause issues like this or if there is some other steps I should be taking when modifying the host file?

2
  • 1
    Why don’t you just launch notepad as an Administrator then open the hosts file? Hosts file was never designed to do what your trying to do with it.
    – Ramhound
    Commented Oct 12, 2023 at 7:04
  • 1
    Your problem is only with the number of entries, not with the way you edit it. Large hosts files can cause severe problems with DNS resolution.
    – Daniel B
    Commented Oct 12, 2023 at 7:39

1 Answer 1

1

Despite a comment suggesting that you should not copy the hostsfile and put it back, this is exactly what I do too.

There is however one important thing to note. If you download a hosts file from elsewhere, you can't just copy that to your C drive, and from there copy it to the windows folder and expect it to work. The downloaded file will have different ACL.

The only way for this to work is to copy the hostsfile to a different location, open the file with notepad, open the other hostsfile, copy over the text, save the hostsfile and copy it back to its original location.

If you still have the original version, copy that back and see if it fixes your issue. If not, delete the hosts file altogether and reboot.

Windows will create a new file.

Keep in mind, that an invalid entry in the hostsfile could actually make everything being blocked, so its perfectly possible that your hostsfile has good permissions, but that one entry blocks it.

For example, I used Microsoft DNS server on my domain controller to block a specific .com address, but I set it up with a container for .com and added a subdomain for the few .com domains that I wanted to block. I did not realize that the .com entry, even without an ip address was not making all .com addresses fail. Something similar can be the case on your end.

1
  • Thank you for your suggestions. I will try this when I get back to my computer (As far as deleting and rebooting). I don't know if there are bad entries since there are so many but I'll see what I can do. Also, 1 comment above suggested that the issue can also be with the number of entries. Do you know if this can also be an issue?
    – Jason
    Commented Oct 12, 2023 at 14:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .