Knowledgebase: Shared Hosting

Updating Your Computer's Hosts File

Posted by on July 19 2013 03:42 PM

The hosts file is a file on your computer which maps hostnames to IP addresses. The hosts file is a text file that can be opened or modified in any text editor, such as Notepad or Wordpad. Updating your hosts file is a way to preview your site as it will load from HostMySite's web server. Modifying this file tells your computer to ignore the existing DNS settings for the site, and instead to only look for the website on the IP you specify. This is very useful for development purposes, or when you are moving your website to our servers and want to test before you go live on the new server.

Note: HostMySite does not condone nor support modifying your system files. Please do so at your own risk or consult with your system administrator before doing so.

Before updating your hosts file, you will need to obtain the new IP address for the site.

  • To find the server IP for a Windows subscription: From the control panel home tab, click "Manage Website" under the Websites section. Click the Web tab to view your IP address.
  • To find the server IP for a Linux subscription: From the control panel home tab, click "Manage Website" under the Websites section. Click "Web Hosting Settings" to view your IP address.

Once you have found your new IP address, you will need to add two entries to your hosts file. These two lines will contain both the IP address to which you want the site to resolve and your domain name. It is best to follow the format of any previous entries or examples for the order of the IP address and domain name. Do not remove any existing lines, such as the default localhost line, when updating the hosts file. An example of the new lines to add is below:

1.2.3.4  yourdomainhere.com
1.2.3.4  www.yourdomainhere.com

Once the hosts file has been updated, save your changes and browse to your domain’s URL to see the content on the new server and to continue to develop your site. You may need to clear your browser cache in order to view the correct content.

Once you are done developing and/or testing your site using this method, you will want to update your site's DNS to point to the new IP or name servers. At that time, you should also remove (or comment out) the lines previously added to your hosts file, to ensure that if your site's IP changes in the future, you are not still forcing your computer to view the old IP address. You can deactivate a line by prefacing it with a "#". This will cause the line to be ignored when the file is utilized.

Here are the locations of hosts file paths for popular operating systems:

  • Linux: /etc/hosts
  • Macintosh OS X: /etc/hosts
  • Macintosh OS 9: In System Folder>Preferences, in the System Folder, see if you have a "Hosts" file. If not, create one in a text editor.
  • Windows XP Home: C:\windows\system32\drivers\etc\hosts
  • Windows NT/2000/XP Pro: c:\winnt\system32\drivers\etc\hosts
  • Windows 95/98/Me: c:\windows\hosts
  • Windows 7/Vista: c:\windows\system32\drivers\etc\hosts
  • Windows 8: c:\windows\system32\drivers\etc\hosts

If you have any further questions that were not answered in this article, please contact us.


Copyright © 2016 HostMySite