IMPORTANT: While reviewing this article, if you are not sure exactly what you need to do, we recommend watching the video above.
NOTE: The following information is intended for Windows users. If you are using a Mac, please see our article on How to Edit Your hosts File Using Mac OS X
What is a hosts File Modification?
A 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, and you are working with domain-name-dependent software (ie. A Content Management System (CMS) such as Joomla! or WordPress).
How Does a hosts File Modification Work?
The image below depicts the process of resolving a domain to an IP address using various devices. In the image, the hosts file on “Your Computer” has been modified with the following code:
Since the hosts file was only modified on “Your Computer“, only that device will resolve the domain: example.com to the IP address: 188.8.131.52.
Other devices, that do not have the hosts file modified, will resolve to the IP address: 172.16.0.0, found in the DNS zone–present in the name servers that the domain is pointed to.
How to Perform a Hosts File Modification
Follow the sections below to learn how to make a hosts file modification.
Run Notepad as administrator
To perform a hosts file mod, 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 otherwise. 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, we need to open our hosts file. With Notepad already open, click on “File”, then “Open…”. As the hosts file is not a standard .txt file as Notepad will look for by default, you will change the drop down in the bottom right that says “Text Documents” to instead display “All Files(*.*)” Navigate to the location of your hosts file and double-click on it to open the file in Notepad.
Locate the IP address that is associated with your account
- Log into cPanel
To the right you should see a column of stats describing your account. Look for Server Information and click on that link.
Scroll down to where you see “Shared IP address”. If you have a dedicated IP, it will say “Dedicated IP” instead. This is the information that you will need for your hosts file mod.
Edit Your hosts File
Now that you have your hosts file open, its time to edit it. Within your hosts file, you should see something similar to the following:
# 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
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a ‘#’ symbol.
# For example:
# 184.108.40.206 rhino.acme.com # source server
# 220.127.116.11 x.acme.com # x client host
WARNING: Be sure to make a backup of your hosts file prior to making changes! To do so, you may follow these steps:
- In Notepad, click on “File” and select “Save As…”
- In the file name, enter something you will remember such as hosts_file_09.16.2013
- Click “Save”
Using the information you have gathered you will add some lines to your host file. They will look something like this:
After making the change, click on “File”, then “Save”. You have now made your hosts file modification.
Using Windows 8 and Windows 10 to Change your Hosts file
Dealing with Defender in Windows 8 when Modifying the Hosts file
If you are using Windows 8, Windows Defender is running by default and it prevents the change of the hosts file. You will need to allow this file to be edited by going into Windows Defender and performing the following steps:
- Navigate to Windows Defender hover 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.
- When Windows Defender opens, click on the tab labeled Settings.
- Next, type in the location of the hosts file based on location of the Windows installation. Here’s the default path: c:windowssystem32driversetchosts
- Click on the Add button and you’ll see it added to the list beneath the file locations.
- Click on Save Changes in the bottom right and then close Windows Defender.
- The next step will be actually edit 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.
- Open the file as per your HOSTS file path.
- 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 make a change to the 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.
- Login as your Administrator User
- Right-click on the Windows icon in the tool bar.
A pop-up menu will appear. Look for Powershell (Administrator) then click on this option.
You will see a Window notification pop-up asking if you wish allow permission for the application to make a change. Click on Yes to continue.
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.
- 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.
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.
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.
- 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 can 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
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: