How to Edit the Local Host file in Windows 10

This brief tutorial shows students and new users how to edit or modify Windows 10 local host files.

When you think of a host file, think of it as a plain-text file used by the operating systems to map IP addresses to the hostname on the local computer. The host’s File has priority over DNS.

When you type a domain name in your browser to go to a website, your computer translates the domain name your typed into an IP address and connects to the server that hosts the website.

While translating the name to IP, the local host’s File is the first File your operating look at. If the IP to domain mapping isn’t included in the host file, then it looks up a DNS server online. This is how the process works.

When dealing with a host file, the IP address and the domain or hostname should be separated by at least one space or tab. The lines starting with # are comments and are ignored.

Open Windows 10 Hosts File

The process of editing Windows 10 host files is simple. To add an entry or modify the host’s File, simply open the host’s File at the path below using Notepad or any other text editor.

c:\Windows\System32\Drivers\etc\hosts

A similar line below should appear in 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

Changes you make to the host’s File take effect immediately. If you want to undo changes to the host’s File, simply open the File and remove the lines you added or precede the line with a # to ignore it.

Add Host Records

The host’s File must be opened as an administrator on Windows systems. If the host’s File is not opened as an administrator, it won’t allow changes to be saved.

To open as an administrator, follow the steps below:

  • Press the Windows key and type Notepad in the search field.
  • Right-click on the Notepad icon and select Run as administrator.
  • In Notepad, click File then Open. In the File name field, paste¬†c:\Windows\System32\drivers\etc\hosts
Windows Hosts edit

For example, to add an entry to translate 127.0.0.1 to example.com, open the host’s File and add its entry by scrolling down to the end of the File and add your new entries:

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
# 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
127.0.0.1               example.com
...

Save the File and exit.

As we said above, the changes take effect immediately. You will be able to example.com in your browser as soon as you save the File.

Conclusion:

This is how one adds or modifies Windows 10 hosts file entries.