Hosts file is an important system file that stores configuration for IP network protocol. It is used to map the hostnames to IP addresses. It is often modified to redirect domain names to local addresses, to block malicious sites or sites with inappropriate content, for web development, etc.
It can also be abused by spyware and other malware to redirect domain, for things like phishing your Internet banking to other IP address to steal your bank account login information.
The Hosts file is stored in a simple text file format and can be found as "hosts" without any file extension in the Windows\System32\Drivers\etc folder.
Example of not customized Hosts file in Microsoft Windows:
# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
# 102.54.94.97 rhino.acme.com # source server
# 38.25.63.10 x.acme.com # x client host
# localhost name resolution is handled within DNS itself.
# 127.0.0.1 localhost
# ::1 localhost
Edit hosts file with Microsoft Windows Notepad
Windows Notepad is a simple text editor installed in Microsoft Windows operating system. It can be also used to edit hosts file.
Step 1 - View system and hidden files
Because Hosts file is hidden system file, you need to enable viewing of hidden and system files/folders in the Windows Explorer.
Open the Control Panel → Apperance and Personalization → Folder Options. Click on View tab and select Show hidden files, folders, and drivers option. Click on Apply and OK buttons.
Windows folder options
Step 2 - Open and edit hosts file
Start Microsoft Windows Notepad as Administrator (click on Notepad icon by right mouse button and select Run as Administrator option).
Windows Notepad Run as administrator
Click on File menu → Open... (also Ctrl+O shortcut) → select the All Files option in file type box and navigate to the C:\Windows\System32\Drivers\etc folder.
Windows Notepad open hosts file
Double click on hosts file and now you are able to edit it.
Windows Notepad editing hosts
After you finished the editing click on File menu → Save (also Ctrl+S shortcut).
Step 3 - Flush DNS cache
To load new settings from customized hosts file to system Open Windows command line (press Win key → type cmd.exe and press Enter) and type ipconfig /flushdns command. Also you can restart the computer.
Windows Command Line flush DNS cache command