How to test website using domain name before DNS is propagated?

If your domain is not registered or you domain is still pointing to old hosting server, you can still test your new website using your domain name on the new server. The way to do this is to make your computer resolve the DNS for your domain to the new server instead of asking domain's DNS server to resolve it for you.

This is how it works. Your computer has a "hosts" file that contains domain and IP address mapping. When your browser loads up the website, it first checks this local hosts file to resolve the domain to its IP address. If it cannot find it in that file then it goes out to the proper name servers to resolve it. Since the actual name servers for that domain either are not setup or point the domain to old hosting server, we can use hosts file to have the computer resolve the domain locally.

On Windows XP/Vista/7/8, this file is located at this path on your computer: c:\windows\system32\drivers\etc\hosts and on Mac this file is located at /private/etc/hosts

On Windows, first you need to open Notepad by right clicking and selecting Run As Administrator. This is important otherwise you cannot edit the file. Then you open the hosts file from File > Open menu by browsing to that path. You will need to change the option on File Open Dialog from "Text Documents (*.txt)" to "All Files (*.*)". This option is located towards the lower-right corner. This will allow you to see the "hosts" file listed in the dialog box that does not have any extension. It is just "hosts" file and not "hosts.txt".

Once the file is opened, you can see it has simple one line entries with IP address and domain name. All lines that start with # are comments and are ignored by the computer. Add two new lines with your server IP address where the domain is hosted and is setup to use that IP.

IP_ADDRESS yourdomain.com
IP_ADDRESS www.yourdomain.com

Save this file and restart your browser (Chrome, Firefox, etc.). Now when you access your website, it will resolve locally and go to your new server. Test the website and once you are done, remove or comment out those lines by adding # before IP address. Save the file and restart browser. Now when you load the website, it will go to old server or however the actual name servers of the domain are setup.

This is a very simple yet powerful technique to test your website. 

If you are on a Mac the file is located at /private/etc/hosts

Open terminal. Go to the that folder /private/etc/ and use nano editor to open the hosts file:

sudo nano hosts

Use the same exact format as listed above for hosts file and add two lines i.e.

IP_ADDRESS yourdomain.com
IP_ADDRESS www.yourdomain.com

Press Ctrl+o and accept changes to save the file. Press Ctrl+x to exit.

Note: To test that your local hosts file is indeed resolving to new IP, you can go to Command Prompt on Windows or Terminal on Mac and issue this command:

ping yourdomain.com

This will show you the IP address in result and response from the remote server. 

When done testing, make sure to undo the changes in hosts file. If you face any problem, please contact support for further assistance.
  • 4 Users Found This Useful
Was this answer helpful?

Related Articles

Do I need a domain name for hosting account?

Yes, you need a domain name to host your web site. If you need help in choosing a domain name or...

Can you register a domain name for your clients?

Yes we can help you register the domain. You can choose a domain name at the time of ordering...

How much it costs for domain names? Is it included in hosting charges?

The cost of domain name can vary depending on the TLD (top level domain e.g. .com, .org, .ca,...

Which domain names do you support? I have an International domain name.

There is no restriction of domain name. If you can register a domain name, we can host it for you...

Can I create sub-domains?

Yes, you can create any number of sub-domains from your control panel.