DNS override

How to edit ‘hosts’ file on Windows 10

Here are the easy steps to modify the hosts file to manually map host names to IP addresses on Windows 10.

Edit hosts file on Windows 10

On Windows 10, it’ll come the time when you may need to edit the “hosts” file to manually override the DNS settings for a particular domain or computer in the network. The hosts file has been around for a long time, and it can come in handy in many scenarios.

For example, if you’re moving a website to a new host provider, and you need to move the files to the new server before switching the domain to the new Internet Protocol (IP) address. You want to block certain websites from being accessed using your computer. Or when you don’t have a local Domain Name System (DNS) server configured in the network, and you need to map an IP address to a computer name so you can contact the device using its name.

Whatever the reason it might be, it’s very simple to edit the hosts file on Windows 10 using the Notepad.

In this guide, you’ll learn the steps to modify the hosts files on Windows 10 to map host names to IP addresses.

How to modify the ‘hosts’ file using Notepad

Use these steps to modify the hosts file, you need to add two entries, including the IP address of the remote host or application to a the friendly address you want to use:

  1. Open Start on Windows 10.

  2. Search for Notepad, right-click the result, and select Run as administrator.

  3. Click on File.

  4. Select the Open option.

  5. Browse the following path:

    C:\Windows\System32\Drivers\etc\
  6. Use the drop-down menu, next to “File name,” and select the All Files option.

  7. Double-click the hosts file.

    Hosts file location on Windows 10
    Hosts file location on Windows 10
  8. Type the IP address of the remote host followed by the domain or computer name you want to use to reach the device or application.

    Quick tip: Use one entry per-line.

    Hosts file on Windows 10
    Hosts file on Windows 10
  9. Click on File.

  10. Select the Save option.

Once you complete the steps, you can test the changes by opening Command Prompt and using the ping command (for example, ping google.com) to make sure the host is being reached.

If you want to block your computer from accessing certain websites, you can use the loopback address (127.0.0.1) followed by the domain name (for example, 127.0.0.1 website.com) — though, using the built-in Windows Firewall or a third-party security software can be more suitable for the job.

We’re focusing this guide on Windows 10, but you can use these instructions on Windows 8.1 and Windows 7.

Update August 15, 2019: This guide was originally published in August 2017, and it’s been revised in August 2019.