Host File for Web Development

Our goal

We’re going to edit the hosts file on our PC to make our servers IP address (e.g. 174.120.31.21) resolve to rockyrasonable.com, just like what a DNS server does when example.com’s name servers have been changed to point to the new hosting.

Configuring the server

All server configurations are different but the principle is generally the same, we need to find out/set our example.com to appear in the web browser when we visit our example IP of 174.120.31.219. For this example I’m going to explain the process on a Cpanel driven server (from this you should be able to get an idea of how this would be achieved through other management software packages).

  • Configure your web space for rockyrasonable.com and upload all your files to it
  • Login to Cpanel
  • Select Server from the left-hand menu
  • Go to the IP Addresses – This should present you with a list of IP addresses assigned to your server, when you configured the hosting for example.com you will have selected one of these IP addresses (you may even only have one IP address in this list)
  • For each IP address there’s a column titled Hosting with a link showing the number of domains assigned to that IP address, click the link that corresponds with the IP address you selected for the web space
  • Select rockyrasonable.com and click Set As Default – You can only select one default domain to be displayed if you visit that IP address in a browser
  • Make a note of the IP address (e.g. 174.120.31.219)
  • Visit 174.120.31.219 in a web browser – You should be presented with your newly uploaded site for rockyrasonable.com

Editing the hosts file

PC’s have a hosts file that we can edit to make 174.120.31.219 resolve to rockyrasonable.com just as if the name servers for rockyrasonable.com had already been changed.

  • Open the hosts file
  • Edit and save the hosts file
  1. Go to the Start menu and choose Run. Type the following in the Run dialog box:
    1. For Windows NT and Windows 2000
      1. C:\winnt\system32\drivers\etc
    2. Windows XP, Windows Vista or Windows 7
      1. C:\Windows\System32\drivers\etc
  2. Click the OK button (This should open a window with several files in it.)
  3. Find the file called ‘hosts’ and double–click it. If prompted, specify that you would like to choose a program to open the file with from a list of programs.
    1. Choose ‘Notepad’ from the list of available programs.
  1. Start typing on a new line at the bottom of the file.
    1. To do so, place your cursor at the very end of the last line and hit ‘Enter’ to start a new line.
  2. Type these two lines of text like this example:
    (use your server IP address and your site domain in–place of the defaults below)
    [code]174.120.31.219 rockyrasonable.com[/code]

    [code]174.120.31.219 www.rockyrasonable.com
    [/code]

  3. Close the hosts file and save it when prompted.

PLEASE NOTE: At this point you should be able to view and publish to your web site using your domain name. After 3–4 days, you will want to undo this change to your hosts file so that you can check to see that your domain name is now resolving without assistance over the internet.

  • Undo the Hosts file change (after you have confirmed that it is resolving properly)
  1. Open the hosts file as described above.
  2. Delete the information that you added previously and close the file.
  3. Choose to save the changes to the hosts file when asked.

Facebook Comments

3 Responses to “Host File for Web Development”

  1. Natalie says:

    I genuinely like your innovative angle that you have on the topic. Certainly wasn’t planning on this at the time I begun browsing for tips. Your ideas were totally simple to understand, so I pondered precisely why I hardly investigated at this in the past. Happy to find out that there’s an individual online that obviously understands exactly what she is talking about. Exceptional piece of work

  2. This is one of the most honest blogs I have ever read. Nothing overcomes good first hand experience on topics. Thank you for being sincere about this.

  3. Fantastic information with regard to upload files for having myself personally begin. I am going to keep this particular website link and return to this.

Leave a Reply


Related Posts