Some anti-virus, anti-sypware/malware, and firewall software maintains an open handle (with no write share permissions) to the Windows Host file, keeping this file open so no other program can edit it (…effectivly locking it).
The file is -
C:\Windows\System32\drivers\etc\Hosts
The most common Hosts file locker is SpyBot Search & Destroy. Others can be: ZoneAlarm, SpywareBlaster, Ad-Aware, WinPartol, HostsMan, etc.
For Spybot S&D -
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'
For ZoneAlarm -
Firewall - Main - Advanced Button - Advanced Settings Uncheck: "Lock Host File". Reboot. *you might also need to disable or configure ZoneAlarm's OSFirewall
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).
There are two 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.
Windows Sysinternals Process Explorer
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.
On Windows 8:
Exclude the Hosts file from scanning in Windows Defender
On Windows 7 and lower:
Exclude the Hosts file from scanning in Windows Security Esentials.
Settings - Excluded files and locations File locations: (type in...) C:\Windows\System32\drivers\etc\ Click Add Button
For Kaspersky:
Settings - Threats & Exclusions - Exclusions - Settings Add - Select file or Folder: C:\Windows\System32\drivers\etc\
Notes
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:
HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\DataBasePath