Some anti-virus, anti-sypware/malware, and firewall software locks the Windows Hosts file so no one can edit it (by maintaining an open file-handle with no write share permissions on this file).
The file is -
The most common Hosts file locker is SpyBot Search & Destroy. Others can be: ZoneAlarm, SpywareBlaster, Ad-Aware, WinPartol, HostsMan, etc.
Try to locate the application(s) that are responsible for this, and turn off the Hosts file lock in their settings (or uninstall/remove the application).
Unlocking the Windows Hosts File
With the Advanced Mode active Tools section IE Tweaks section Uncheck: "Lock hosts file as protection against hijackers"
*you might need to start Spybot by right-clicking on it, and selecting ‘Run as admin’
Firewall - Main - Advanced Button - Advanced Settings Uncheck: "Lock Host File" Reboot.
*you might also need to disable or configure ZoneAlarm’s OSFirewall
There are free tools you can use to find out who/what is locking this file. They will show you which process is maintaining the lock, and you can infer by the process’s name/path what the application is. Then open the application and go through the application’s settings.
Exclude Hosts File From Scans
Aside from unlocking the Hosts file, you’ll also need to make sure changes to this file are not marked as malicious and then undone – by excluding the Hosts file location from scanning.
Windows Defender & Security Esentials
On Windows 8, open Windows Defender. On Windows 7 and lower, open Windows Security Esentials.
Settings - Excluded files and locations File locations: (type in...) C:\Windows\System32\drivers\etc\; Click Add, and then Save changes
Settings - Threats & Exclusions - Exclusions - Settings Add - Select file or Folder: C:\Windows\System32\drivers\etc\
1. If you are unable to see this file, change Folder View options to: show hidden files and folders, show known file extensions, and NOT hide protected files.
2. The true HOSTS file path (under all Windows versions) is defined in this Registry key: