How do I view my website to test it before changing my name server DNS?
If your domain is registered elsewhere, for example you have a current site with another host - but you are planning on building a new site and moving to Krystal - you might want to set up and test your new site before updating your DNS name servers to point the domain to Krystal.
You'll also find that some Content Management Systems (CMS) like WordPress, Joomla and Magento need you to access the site using the domain name to work correctly.
This article explains how to edit a file called
hosts on your PC or Mac so you view and test your new site before changing your name servers.
For Windows PC's
- Locate the HOSTS file on your computer. Typically it is in one of the following locations:
Location of hosts file
- Open this file with a text editor such as Notepad or Wordpad (For Windows 7 and later, you will need to run Notepad as an administrator to gain access to the file. Right click the application and click "Run as Administrator")
- Once you have the hosts file open in your editor, consider performing a "Save As" so you have an original copy of the file that you can restore later should you need to. You will see two columns of information, the first containing IP addresses and the second containing host names. By default, a windows hosts file should be similar to the following:
You can add additional lines to this file that will point requests for a particular domain to your new server's IP address. You will find your server's IP address in your new account e-mail. This needs to be inserted below in place of X.X.X.X is shown and example.com replaced with your own domain name
e.g. your server is Fluorine with an IP address of 184.108.40.206 and your domain is mydomain.co.uk - your file should look like this:
- Save your changes and then restart any currently open browsers.
- Now visiting www.example.com will load from your new account with Krystal ignoring your current DNS setup.
- Either by start typing Terminal on the Spotlight, or by going into Applications -> Utilities -> Terminal.
- Open the hosts by typing on the Terminal that you have just opened:
$ sudo nano /private/etc/hosts
Type your user password when prompted.
- The hosts file contains some comments (lines starting with the # symbol), as well as some default hostname mappings (e.g. 127.0.0.1 – localhost).
Simply append your new mappings underneath the default ones as per step 3 for Windows above. Or edit one of the default values if you know what you are doing!
You can navigate the file using the arrow keys.
- When done editing the hosts file, press control-o to save the file.
Press enter on the filename prompt, and control-x to exit the editor.
- On Leopard, you can issue a simple Terminal command to flush the DNS cache, and have your host file changes take immediate effect:
$ dscacheutil -flushcache