Question: How do I access a website my new website before making it live on the Internet? We are running a test site and want to debug it before publishing the site on the Internet.
Answer: An easy way to access your new site before publishing it live on the Internet is by using a local hosts file. This should bypass regular DNS lookups and allow you to access the web site using your computer as if it were published live in DNS by using the IP address you specify in your hosts file.
Example: xyz.com is hosted on a server at the IP address 1.2.3.4 and the IP address and domain/host name are not yet resolving to the 1.2.3.4 address. All you need to do to make this work on a Windows or Mac computer is add a line containing the IP address and domain/host name.
On Windows
- Press the Windows key and in the box labeled "Type here to search" type: cmd. When you see the Command Prompt App click on "Run as Administrator"
- When you see the C:\> prompt, type in the following: notepad C:\Windows\System32\Drivers\etc\hosts (copy and paste)
- This should open the hosts file in Notepad. Go to the last line of the file and add: 1.2.3.4 xyz.com www.xyz.com - of course use the correct IP and domain name your are trying to set up for access.
- Open your web browser and you should see the site on the server you specified.
On Linux
- Open a terminal window and open the hosts file in a text editor such as vi. E.G. vi /etc/hosts/
- Append the IP address and domain name at the end of the file and save.
- Open the site on the server you specified.
On MacOS
- Open a Terminal under Applications --> Utilities
- Type sudo nano /private/etc/hosts (you'll need your superuser password)
- Append the IP address and domain/host name as the last line of the file and save.