How to use your HOSTS file to test your webserver before DNS propagation is finished.

This article is intended for customers that want to test their websites before pointing DNS to their server. The method used in this article involves editing the HOSTS file on the customer's local computer.

---

To test your website before DNS propagation is through you can edit the HOSTS file on your local computer. Your computer will use the entries in your HOSTS file before it looks up the current information in DNS. This walkthrough will explain how to edit the HOSTS file on Windows 98/Me/2000/XP/2003 computers as well as on Apple Mac OS9 and OSX machines.

Windows:

  • Locate the HOSTS file on your computer. Depending on the operating system you have, the following are locations you may be able to find this.
    Windows NT/2000/XP/2003/2008 or Windows 10  C:\WINDOWS\System32\drivers\etc\hosts
    Windows 95/98/Me c:windowshosts
  • Open this file with notepad or wordpad. In it near the end you will see two columns of information, the first containing IP addresses and the second containing host names. The only one in a windows hosts file by default looks like this:

     

    127.0.0.1 localhost
    We are going to add lines just underneath the existing line that will point request from your computer to your new server's IP address. Suppose the IP address of your new server is 10.10.10.53 and the domain name you want to test is www.my-domain.com, you'd make a two line entry like this:
    10.10.10.53 my-domain.com

    10.10.10.53 www.my-domain.com

  • Save the file with these new entries and close all open browsers. You can now go to either http://www.my-domain.com or http://my-domain.com to test your new server.
  • When finished testing your new server don't forget to reopen the HOSTS file to remove the lines you added above.
Mac OS9:
  • Look in System Folder:Preferences, and in the System Folder itself. See if you have a file named "Hosts". If not, create one in a text editor.
  • Open this file with any text editor. In it near the end you will see two columns of information, the first containing IP addresses and the second containing host names. There might be an existing line that looks like this:

     

    127.0.0.1 localhost
    We are going to add lines just underneath that line that will point request from your computer to your new server's IP address. Suppose the IP address of your new server is 64.207.100.100 and the domain name you want to test is www.my-domain.com, you'd make a two line entry like this:
    10.10.10.53 my-domain.com

    10.10.10.53 www.my-domain.com

  • Save the file with these new entries and close all open browsers. You can now go to either http://www.my-domain.com or http://my-domain.com to test your new server.
  • When finished testing your new server don't forget to reopen the HOSTS file to remove the lines you added above.

Mac OSX
  • To edit the hosts file on Mac OSX open a Terminal window by going to Applications -> Utilities A window will appear that has something like:
    Last login: Thu Nov 11 11:46:46 on ttyp1

    Welcome to Darwin!

    520bro057036b:~ user-name$
  • At the prompt type (or cut and paste):

     

    sudo echo "xxx.xxx.xxx.xxx domain-name.com" >> /etc/hosts

    where xxx.xxx.xxx.xxx is replaced with the IP of your server and domain-name.com is replaced with the domain name you'd like to test. Hit "Enter".

  • Enter the password for your computer if the prompt asks for it and hit "Enter".
  • Your hosts file has been edited, to make sure the changes have applied close all open browser windows (Safari, Mozilla, Internet Explorer).
  • When finished testing please don't forget to remove the line you added to the hosts file by opening a terminal and typing (or cutting and pasting):
    cd /etc/

    perl -e 'open(F, "hosts"); @array = (); close(F); open(FH, "> hosts");print FH @array[0..($#array - 1)]; close(FH);'

    Hit enter after each line, this will remove the last line in your HOSTS file. If you added more than one entry you'll have to repeat the last command the corresponding number of times.

 

NOTES:

  • Revion.com does not support this configuration. We are providing this information to you as a courtesy. We are not Microsoft Support Technicians so you need to use this work around at your own risk. Always, always, always back up your files
  • 684 Kunder som kunne bruge dette svar
Hjalp dette svar dig?

Relaterede artikler

Do you provide domain name registration?

No, we do not provide domain name registrations. Please take your time to search for the most...

Can you host international domains?

Yes, absolutely! We can host virtually any international/foreign domain name.

How long does it take before my new domain name is active?

New registrations are generally ready within 24 to 72 hours

Can I transfer an existing domain name to Revion.com ?

Absolutely! As a matter of fact we recommend using our reliable and secure DNS service. Please...

Do you allow subdomains?

You can have as many subdoamins as you wish. A subdomain example: jeff.xyzabc.com