The hosts file is a special file on your workstation computer that will store IP and name information. This file is checked by your workstation before DNS. This means you can override any public DNS settings to point to any server.
This feature is very useful in testing websites as it will allow you to control which IP your local computer will use regardless of what is set in the public DNS.
When moving a website from another host, this is the most effective way of testing your website before updating the name servers and DNS records.
This change only affects your local workstation.
Edit Your Hosts File
Windows
- If you're on Windows 8 or 10, click on your Start Menu, search for "Notepad"
For earlier versions of windows click on All Programs -> Accessories -> Notepad - Important Right-click on Notepad and select "Run As Administrator".
- In Notepad, click on the File menu and select Open
- Paste the following into the File Name: box
C:\Windows\System32\Drivers\etc\hosts
. - Click on Open
- Make your changes (see the next section) and then click on Save
Linux
- Open a terminal window
- Edit the /etc/hosts file as a root user. For example:
sudo nano /etc/hosts
- Make your changes (see the next section) and then click on Save
Mac
- Go to the Finder and click on the Go menu
- Select Utilities
- Double-click on the Terminal icon
- Enter the command:
sudo nano /etc/hosts
- Make your changes (see the next section) and then click on Save
Make Your Changes
Your hosts file probably already has some content in it. Leave the content as it is and move your cursor to the end of the document and add a new line.
Next, you will need to type in the IP address of the server you want to connect to. This would be your new UpTime hosting server IP.
You can get this IP address from your Woohoo! Your new hosting is good to go! email we sent you when you ordered your plan.
Look for the server Server Information section and you will see the Server IP. The IP should be 4 numbers separated by dots, for example, 108.61.169.233
Type this number into your hosts file and then add a space and then type the domain name of your website. It should look something like this:
108.61.169.233 your-domain-name.com.au
It's also a good idea to add another entry with your www. address, so on the next line add the same thing but with your www.
You should now have something that looks like this:
108.61.169.233 your-domain-name.com.au
108.61.169.233 www.your-domain-name.com.au
Now save and close your hosts file.
Open up your web browser, It's a good idea to open an InPrivate/Incognito tab and navigate to your website.
You should now see the UpTime hosted version of your website.
If you need to see the live version again of your website you will need to remove the entries you added before.
It's a good idea to comment them out instead of deleting them as this makes it easy to activate them again.
To comment out the entries, all you need to do is add a hash at the front, like so:
#108.61.169.233 your-domain-name.com.au
#108.61.169.233 www.your-domain-name.com.au
Testing and Launching
Once you have completely tested your website on your new UpTime account you should update the DNS on your old host to point to the IP Address you used above. Update the name servers on your domain and then finally you can remove the entries from your hosts file.