What a great idea
If it's something specific and is for all computers, the ideal thing is to block it on the router (if it gives the option). If not, on each computer with parental control is much better, as they said 4 years ago in response to the question, search on the internet how they work, besides, most operating systems already have that function.
I know those methods, in case it's about several computers it is certainly more efficient than using the hosts file, but in my case I only want to block sites on my laptop, besides it would be a problem if in the future I wanted to change my router for some reason. I also tend to use the hosts file because it is versatile, it is a small file that only weighs a few kilobytes, it is easy for me to make a backup of it.
I appreciate everyone who responded to me.
Solution:
For some passing reader like me who comes across this topic, I have already found the solution to my doubt, in my case it was a problem with the credentials or permissions of the hosts file. By right-clicking on hosts and going to:
Properties > Security > Group or user names
I needed the name %COMPUTERNAME%\\Users and I just had to add it to solve the problem.
Note: This problem could be solved simply by changing my hosts file to a backup I had saved previously, but it didn't work for me because it always "replaced" the file, it is better to delete the hosts file from the etc directory and place the backup in its place. Keep in mind that this is only one of the possible solutions, since the reasons why the hosts file doesn't work can be several.
