How to test a new website on our server without changing DNS/name servers

If your website is currently hosted elsewhere and you want to build a new website on our server whilst keeping the current website operational this can be done by adding some entries to your computers 'hosts' file.

This will point your website address to our server on your PC only, which allows you to see how your website will appear on our server before changing DNS.

Once you're happy with the new website, you can then change the DNS/name servers to us as normal and remove the entries you added to your hosts file - just so it doesn't catch you out if you were to change hosts in the future.

For Windows users:

Click the start menu icon and search for Notepad.

Right click Notepad and select 'Run as administrator'.

Now that Notepad is open, go to File, select Open then browse to C:\Windows\System32\drivers\etc\ - in the bottom right, change the 'text documents' dropdown to 'all files'.

You should now be able to see a few files, one of which will be called 'hosts', select 'hosts' to open it.

To check which IP to use, log in to cPanel where you'll find the IP to use is under 'Shared (or Dedicated) IP Address'.

There will usually be some text in this file, simply add an entry such as the one below to the bottom of the file, replacing the IP and domain with the correct details.

194.147.120.200 mydomain.com www.mydomain.com

Then go to File, and select Save.

For Mac users:

Open Terminal from the launch pad, or in Finder, under Applications, Utilities, Terminal

Once you have Terminal open, type sudo nano /etc/hosts

To check which IP to use, log in to cPanel where you'll find the IP to use is under 'Shared (or Dedicated) IP Address'.

There will usually be some text in this file, simply add an entry such as the one below to the bottom of the file, replacing the IP and domain with the correct details.

194.147.120.200 mydomain.com www.mydomain.com

When you go to your website in your browser, it'll now be pointing to our server (but only on your device).

 

If you're still seeing your current website - It's a good idea to access your website in a private / incognito browser session, or to clear cache before hand just to ensure you aren't seeing a cached version of the site.

 

If this doesn't help, an additional check you can do to ensure the host entry has worked is to open Command prompt (Windows) or Terminal (Mac) and type: ping mydomain.com to make sure its showing our servers IP. On Mac, you have to press CTRL + C to stop the ping test from running.

If the ping test is showing an incorrect IP address, then you may need to open Command prompt (Windows) and type: ipconfig /flushdns or for Mac, open Terminal and type: sudo killall -HUP mDNSResponder - however this isn't usually required. Note that there is no confirmation/output on Mac after running the command.

 

If you run antivirus software, this can sometimes lock your hosts file, which will generate an error when you try to save the hosts file, such as saying it's locked, file is in use, or access denied.

To get around this you may need to temporarily disable your antivirus software.



Was this answer helpful?

Add to Favourites
Print this Article

Also Read
Official cPanel Manual (Views: 2479)
Official WHM Manual (Views: 2251)
PHP Time Zone Errors (Views: 670)