If you have a website located on a hosting account but the DNS for your domain does not currently resolve to that hosting account, you can configure your computer to override public DNS settings in order to view the website on that hosting account.
This can be useful if,
- You are transferring your website to a new server or web host, and would like to view the website on the new server before you have updated the DNS or nameservers for the domain
- You have already transferred your website to a new server and updated the DNS/nameservers, but now wish to view the website as it existed on the old server
To override the DNS for your computer, you need to edit the "hosts" file on your computer, and add an entry for the hostname and the IP address you want it to resolve to, like such:
1.2.3.4 www.example.com.au
1.2.3.4 example.com.au
...where "1.2.3.4" is the IP address of the server to which you uploaded/transferred the new website, and "example.com.au" is your website's domain name. To find out what IP address you need to use, ask the hosting provider of the version of the website you want to look at for "The IP address of the hosting account for the website www.example.com.au".
Depending on whether you use Windows, Mac or Linux, the process for editing your hosts file will be different.
- For Windows, hit Start, search for notepad, right-click on the Notepad app and choose "Run as Administrator. In Notepad, go File > Open, paste in "C:\Windows\System32\drivers\etc\hosts" and press Enter. Make the changes as described below, then go File > Save, then File > Exit (or leave it open if you want to revert your changes soon.) You may need to restart your web browser to clear your DNS cache.
- For Mac, open spotlight and search for Terminal and open it. Copy-paste the command
sudo nano /etc/hosts
and press Return; then type your Mac user password when prompted and press Return (the password won't show). Make the changes as described Above, then press CTRL+O and Return to save, then CTRL+X to exit the text editor. You may need to reload your DNS cache, to do this, copy-paste the commandsudo killall -HUP mDNSResponder
and press Return. Then close Terminal (or leave it open if you want to revert your changes soon.)
(If the above instructions don't work for you, try Googling for "host to change hosts file <my exact operating system and version>" to find specific instructions for your computer.)
When you've finished testing, don't forget to remove the entry and save the hosts file, otherwise you'll run into confusion if you ever change the IP address of your website in the future.