If you’re experiencing network or website connectivity issues, the Hosts file may be part of the problem. This article explains what the Hosts file is, how it works, and why resetting it to the default state can resolve common connection issues.
What's the Hosts file
The Hosts file is a plain‑text system file used by the operating system to map human‑friendly hostnames (such as contoso.com) to numerical Internet Protocol (IP) addresses. This mapping allows the system to identify and locate devices on an IP network and is a standard part of an operating system’s IP implementation.
Each entry in the Hosts file appears on its own line and includes an IP address followed by one or more hostnames, separated by whitespace (tabs or spaces). Lines beginning with a hash character (#) are treated as comments, and blank lines are ignored.
If the Hosts file is modified from its default state, it can override normal network name resolution and cause connectivity issues. Resetting the file to its default configuration can often help resolve problems accessing websites or network resources
Reset your hosts file
To reset the Hosts file back to the default, follow these steps according to your operating system:
-
Press the Windows key, type Notepad, and select the Notepad app icon.
-
Copy the following text, and then paste the text into the file:
# 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
-
On the File menu, select Save as and type "hosts" (with quotes) in the File name box.
-
Change the Save as type to All files (*.*). A hosts file can't have a file extension.Â
-
Save the file to the desktop and close Notepad.
-
Search for %WinDir%\System32\Drivers\Etc, and then select the File folder icon.Note: Typically this is C:\Windows\System32\drivers\etc
-
Right-click the existing Hosts file, select Rename, and then change the file name to "Hosts.old".
-
Copy or move the Hosts file that you created from the desktop to the %WinDir%\System32\Drivers\Etc folder. If you are prompted to enter an administrator password, select Continue.
​​​​
To reset the Hosts file back to the default, follow these steps:
-
Press the Windows key, type Notepad, and select the Notepad system icon.
-
Copy the following text, and then paste the text into the file:
# 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
-
On the File menu, select Save as and type "hosts" (with quotes) in the File name box.
-
Change the Save as type to All files (*.*). A hosts file can't have a file extension.Â
-
Save the file to the desktop and close Notepad.
-
Search for %WinDir%\System32\Drivers\Etc, and then select the File folder icon.Note: Typically this is C:\Windows\System32\drivers\etc
-
Right-click the existing Hosts file, select Rename, and then change the file name to "Hosts.old".
-
Copy or move the Hosts file that you created from the desktop to the %WinDir%\System32\Drivers\Etc folder. If you are prompted to enter an administrator password, select Continue.