Overriding public DNS to preview your site Print

  • 0

You can edit the hosts file of your local machine/computer to override public DNS and force your computer to load a site from our platform, when public DNS points to a platform other than ours. 

Firstly, log in to the cPanel held with us that contains (or will contain) the site you'd like to preview and make a note of the "Shared IP address" displayed on the right hand side.

Mac OS
If you're using a Mac with OS X, to edit your /etc/hosts file, open a Terminal window and run the following command:
sudo nano /etc/hosts

You may be asked for your password to edit the file. Enter your password. Then add an entry to your /etc/hosts file in the following format (without the bracket) :
[IP address]  [domain name]
Then save the file.

For example, if your domain is hello.co.uk and the "Shared IP address" displayed in your cPanel is 1.2.3.4 (these are generic examples), the line you'd add to /etc/hosts on your mac is:

1.2.3.4 hello.co.uk www.hello.co.uk

Windows
If you're using Windows, to edit your hosts file, open [SystemRoot]\system32\drivers\etc\hosts and edit the file as the administrator using a text editor such as notepad. (The hosts file usually exists at %windir%\system32\drivers\etc\hosts. by default %windir% is C:\windows which makes the fill path to the hosts file C:\windowssystem32\drivers\etc\hosts). Some versions of Windows require that users have admin privileges to create or make changes to this file. Then add the following entries and save the file:
[IP address]  [Domain name]

For example, if your domain is hello.co.uk and the "Shared IP address" displayed in your cPanel is 1.2.3.4 (these are generic examples), the line you'd add to C:\windowssystem32\drivers\etc\hosts on your Windows system is:

1.2.3.4 hello.co.uk www.hello.co.uk

Linux
If you are using Linux OS,   open the /etc/hosts file using your editor of choice as follows
$ sudo vi /etc/hosts
Then add the lines below to the end of the file in the given format:
[IP address]  [Domain name]
And save the file. 

For example, if your domain is hello.co.uk and the "Shared IP address" displayed in your cPanel is 1.2.3.4 (these are generic examples), the line you'd add to /etc/hosts on your Linux based system is:

1.2.3.4 hello.co.uk www.hello.co.uk

Validating the changes above
After modifying the /etc/hosts file, you can then test that you've correctly made the changes detailed above, using the ping command.
ping domain.tld

If the ping command returns the same IP address that's listed as the "Shared IP address" displayed in your cPanel, you've correctly forced your computer to load the site from your cPanel held with us.

The above only affects the computer to which you make the changes, all other parties see the site loading from the server that public DNS defines.


Was this answer helpful?

« Back