1. Home
  2. Windows

How To Modify The Hosts File On Windows 10

A hosts file is a system file that is found on Windows, Linux, and macOS. On all three operating systems it serves more or less the same purpose; mapping domains to IP addresses. If you’ve never touched your Hosts file, chances are it’s just an empty TXT file on your drive which begs the question, what’s it for? Why do people need to modify the Hosts file? What happens when you add or remove something from this file?

The Hosts file is a relic from the old days of the internet. Back when DNS wasn’t a thing, these files were what translated a domain into an IP. Strictly speaking, they aren’t needed any more but they’ve still been kept around mostly for use in networking. What people generally use the Hosts file now for is to block certain domains though a host file can be used to redirect a website, naming devices on your network, and more. The host file essentially does what DNS does i.e. you give it a domain and an IP address and when you type the domain in your browser, the host file knows which IP to send you to.

Modify The Hosts File

You can modify the host file on Windows 7, 8/8.1, and 10 using the following method. The same rules apply. You will need administrative rights to modify the host file.

Hosts File Location

Go to the following location and look for a file named ‘hosts’.

C:\Windows\System32\drivers\etc\

It’s a simple text file though you will not see the TXT extension appended at the end. To open the file, right-click it, and select Notepad as the app to open it with.

Before you modify the hosts file, it’s a good idea to back it up somewhere. It’s rare that a modification to this file breaks anything serious. At the most, it can cause problems accessing certain websites. Regardless, having a backup is the easiest way to mitigate any problems. If you often modify the hosts file, it might be a good idea to keep a backup of each version.

Add Domain

To add a domain to the host file, you need the domain name, and its IP address.

Syntax:

IP Address Domain Name

Example:

91.198.174.192 www.wikipedia.org

Make sure you do not add http or https before the domain name. Simply add this line to the hosts file, save the change, and restart your browser. You can use a public IP to map a website or you can use private IP address and map a network system or server to its network address.

Block Domain

To block a domain, you need only the domain. You will redirect the domain to your own system. Open the hosts file and look for comment with localhost in it. This is your system.

Syntax:

Localhost Address Domain Name

Example:

127.0.0.1 www.wikipedia.org

Save the change, and restart your browser. A proxy can be used to bypass a domain blocked by the hosts file.

Defaults Hosts File Windows 10

The following are the contents of an unmodified hosts file on Windows 10;

# 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

Hosts File Tools

There are lots of apps that modify the hosts file. They basically provide a GUI for what you can do with just the Notepad. If you’re nervous about modifying the hosts file, you can use one of these tools. Make sure you use a reliable one and compare the changes it makes later just to be on the safe side.

Leave a comment