If you encounter the error You don’t have permission to save in this location when you are trying to save the Hosts file, that means the account that you logged in you doesn’t have administrator permission to save a file or the hosts file is protected by other programs. You may try the following suggestions one by one to check the issue.
To disable hosts file protection in Windows Defender: Open Windows Defender, switch to the “Settings” tab, click on the left side “excluded files and locations” option, click “Browse” button, navigate to the location of the hosts file as C:\Windows\System32\Drivers\etc\hosts, then click on the “Add” button, then click “Save Changes.”
Right-click notepad.exe, then left-click “Run as administrator”. You can now open and edit the Hosts file.
One way that is not recommended for fixing this problem is by modifying the hosts file’s permissions and makes it editable for anyone. Changing hosts file’s permission will make the system vulnerable.