Net30 Hosting Logo

How to Modify Your hosts File Using Windows

What is a hosts File Modification? #

hosts file modification is a simple tweak that is used to “trick” your computer into resolving to a specific IP. This is especially useful when developing your site on our server when your nameservers are not pointed to us yet. This is necessary when you are working with domain-name-dependent software (ie: Content Management System (CMS), such as Joomla! or WordPress).

Since the hosts file was only modified on “Your Computer“, only that device will resolve the domain: to the IP address:

Other devices, that do not have the hosts file modified, will resolve to the IP address:, found in the DNS zone–present in the name servers that the domain is pointed to.

How to Modify Your hosts File #

Follow the sections below to learn how to perform a hosts file modification.IMPORTANT: While reviewing this article, if you are unsure exactly what you need to do, we recommend watching the video above.

Run Notepad as administrator #

To modify your hosts file, you will need to first run Notepad (or any other text editor available to you on the same computer) as administrator. This is because the hosts file is a system file and cannot be modified without elevated privileges. Note: If you are running Windows XP or lower, you won’t need to run it as administrator as this functionality only exists in Vista and above. Locate Notepad within your Start menu. If it is not already there, you can type “notepad” into the search box to show it. Then, right-click on it and click on “Run as administrator”.

Open Your hosts File #

After you have Notepad up and running as administrator, you can then locate your hosts file and open it. While not all Windows versions store it in the same place, it is typically located within c:windowssystem32driversetc and the filename is: hosts. If you do not see it there, other possibilities are as follows:

  • Windows 95/98/Me c:windows
  • Windows NT/2000/XP Pro c:winntsystem32driversetc
  • Windows XP Home/Vista/Windows 7 c:windowssystem32driversetc
  • Windows 8 c:windowssystem32driversetc
  • Windows 10 c:windowssystem32driversetc

Now, you need to open your hosts file. With Notepad already open, click on “File”, then “Open…”. As the hosts file is not a standard .txt file that Notepad will look for by default, you will need to change the drop-down in the bottom right that says “Text Documents” to select “All Files”. Finally, navigate to the location of your hosts file and double-click on it to open the file using Notepad.

Edit Your hosts File #

Now that you have the correct file open, it’s time to modify your hosts file. Within your hosts file, you should see something similar to the following:Copy

# Copyright (c) 1993-1999 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:
# # source server
# # x client host localhost

WARNING: Be sure to save a backup of your hosts file prior to making changes! To do so, you may follow these steps:

  1. In Notepad, click on “File” and select “Save As…”
  2. In the file name, enter something you will remember such as hosts_file_09.16.2013
  3. Click “Save”

Using the information you have gathered you will add some lines to your hosts file. They will look something like this:Copy

NOTE: Be sure to replace with your actual IP address and my-wordpress-site.comand with your actual domain.

After making the change, click on “File”, then “Save”. You have now made your hosts file modification.

Additional Windows 8/10 Necessary Steps #

Configuring Defender in Windows 8 to Modify Your hosts file #

If you are using Windows 8, Windows Defender is running by default and it prevents you from being able to modify your hosts file. You will need to allow this file to be edited by going into Windows Defender and performing the following steps:

  1. Navigate to Windows Defender by hovering over the right corner to bring up the navigation bar. Click on the icon that appears to be a magnifying glass to start a search. Type in “Windows Defender”, click on the icon that appears. It will be labeled “Windows Defender.” Click on this icon and the application will launch.
  2. When Windows Defender opens, click on the tab labeled Settings.
  3. Next, type in the location of the hosts file based on the location of the Windows installation. Here’s the default path: c:windowssystem32driversetchosts
  4. Click on the Add button and you’ll see it added to the list beneath the file locations.
  5. Click on Save Changes in the bottom right and then close Windows Defender.
  6. The next step will be actually editing the file. As per the instructions above, you will need to edit the file as an Administrator. Hover over the right side again, and then search for “Notepad”. Open it as an administrator.
  7. Open the file as per your HOSTS file path.
  8. Make your edits, and click on SAVE by clicking on “File” to bring up the menu. This completes the HOSTS file edit in Windows 8.

Working with Windows 10 to Change Your Hosts File #

When you are working with Windows 10, the main concern you will need to address before you begin is being able to modify your hosts file. You will need Administrator access in order to make the change. If you have any questions concerning administrator access please see Microsoft’s definition of an Administrator for Local accounts or speak with a local Windows administrator. In Microsoft’s documentation, local accounts means “on your computer.” Follow the steps below to quickly and easily make changes to the hosts file.

  1. Log in as your Administrator User
  2. Right-click on the Windows icon in the toolbar.
  3. A pop-up menu will appear. Look for Powershell (Administrator) then click on this option.
  4. You will see a Window notification pop-up asking if you wish to allow permission for the application to make a change. Click on Yes to continue.
  5. When the prompt appears, type in Notepad. Since you are launching Notepad from the Powershell Administrator, it will launch the application with the appropriate administrator permissions.
  6. In the Notepad menu, click on File, then click on Open. You will need to navigate to the folder that contains the hosts file. This is the typical path: c:WindowsSystem32driversetc.
  7. If you do not have show hidden files enabled in your Windows File preferences, you will not see any files. However, type in Hosts, then hit enter. Notice that the file does not have an extension – it’s just “hosts.” This will bring up the Hosts file. Since the Hosts file is a system file, it will be hidden unless you set your Windows file preferences to show hidden files.
  8. At this point, you will see the hosts file. As per the instructions above you will need to have the IP address of the server where you trying to point the URL. Make sure that you follow the example provided and put a space between the IP address and the domain name that you wish to use.
  9. Click on File, then click on SAVE in order to save any changes that you may have made to the file.

As a precaution close the Notepad window and then re-load the hosts file per the beginning steps and double-check to see that your changes have been applied.

How do I know that it worked? #

The easiest way to see that it worked is to just go to your domain. Does it show your new site as it should on our servers? If there were no changes to your site from when you moved it, you might need to run a ping test to ensure that it shows the correct IP.

Flushing Your DNS Cache #

After you modify your hosts file, if your computer has cached your DNS, you will need to clear it. Luckily, we have an article that can teach you how to do just that:

Powered by BetterDocs

Leave a Reply

Your email address will not be published.

For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

I agree to these terms.