Before you edit the HOSTS file in Windows 8.1, you will need to make a little change in Windows Defender. Windows Defender may determine incorrectly that the Hosts file was changed by malware. Defender will automatically remove your custom file and replace it with the default from Microsoft.
To allow hosts file change in Windows Defender, exclude the Hosts file from scanning in Windows Defender. To do this, follow these steps:
- Open Windows Defender.
- On the Settings tab, click Excluded files and locations.
- Under File locations, click Browse.
- Locate and then click the Hosts file.
Note By default, the Hosts file is located in the %systemroot%\system32\drivers\etc folder.
- Click Add, and then click Save changes.
- Exit Windows Defender.
Next step, simply press the "Windows" key, type in "Notepad". Right-click the notepad icon and select: Run as Administrator. OK the UAC prompt.
Open the HOSTS file from Notepad. By default, the Hosts file is located in the C:\Windows\System32\Drivers\etc\ folder.
After edited the HOSTS file, run the command below under CMD to flush DNS cache.
After everything is done. Go back to Windows Defender and remove the exclusion to secure the hosts file from unauthorized edit.