How do I view my new site before making it visible to the public? Print

  • 3

How do I view my new site before making it visible to the public?

When you are making changes to your website it can be helpful to see the site before it goes live. You want to make sure that the site is going to work without any errors before you start sending traffic over to it. You can copy the site and all your content to the server, but how do you test the new setup without changing the DNS (and having the whole world see your site on the new server before it’s ready for prime time)?

The best way to do this is to change your personal computer’s hosts file. When you visit a website, your computer has to look up the IP address for that site so that it knows where to go. Before your computer goes out onto the Internet to find the IP address, it will first check its own local hosts file. The hosts file on your computer is a plain text file that contains a map of hostnames to IP addresses.

By changing the hosts file on your personal computer, you can send only your computer to the new server without affecting the live site at all. In essence, you are “tricking” your computer by manually setting the IP address for a particular website and telling it where to go instead.

The process for modifying the hosts file varies depending on what operating system you are running. The below instructions will guide you through this process on Windows, Mac or Linux on how to change your hosts file.

Windows

Editing the hosts file in Windows can all be done in Notepad.

1. Open a Run prompt

Press the Windows key + ‘R’.

2. Open the hosts file with Notepad

In your newly opened Run prompt, type the following to have notepad open the system’s hosts file:

notepad c:\windows\system32\drivers\etc\hosts

Hit ‘OK’ to open the file with Administrative priviledges.

3. Edit the hosts file

Your hosts file will already contain comments (lines that start with the pound ‘#’ symbol), as well as some default hostname entries (e.g. 127.0.0.1 localhost). Simply add in your custom entry for your domain onto its own new line at the bottom. For example:

5.101.138.188    mywesbite.com

4. Save the hosts file

When you are done modifying your hosts file, press Ctrl+S to save the file. Then you can close notepad.

5. Flush the DNS cache

Typically, you will want to flush the existing DNS cache from your computer so that your host file changes can take effect immediately. You will need to get to a command prompt. Open ‘Run’ as in Step 1 and type:

cmd

Now, inside the command prompt, flush the DNS cache by typing:

ipconfig -flushdns

Click \”OK\”

Now load your site in your browser and you’ll be hitting the new IP location.

Mac

Use Terminal to edit the hosts file on a Mac. The commands are similar to Linux and the hosts file itself resembles a Windows hosts file.

1. Open a Terminal window

Either type ‘Terminal’ into Spotlight or you can navigate to Applications >> Utilities >> Terminal.

2. Open the hosts file

Open the hosts file in an editor by typing in the following in the newly opened Terminal window:

sudo nano /private/etc/hosts

Type your Mac computer password when prompted.

3. Edit the hosts file

Your hosts file will already contain comments (lines that start with the pound ‘#’ symbol), as well as some default hostname entries (e.g. 127.0.0.1 localhost). Simply add in your custom entry for your domain onto its own new line at the bottom. For example:

5.101.138.188    mywesbite.com

4. Save the hosts file

When you are done modifying your hosts file, press Ctrl+O to save the file.
Press enter when prompted for the filename, and then hit Ctrl+X to exit out of ‘nano’.

5. Flush the DNS cache

On a Mac, you will need to run a quick command to flush the existing DNS cache from your computer. This will allow our host file changes to take effect immediately. In the same Terminal window type:

dscacheutil -flushcache

Simply quit Terminal to exit.

Now load your site in your browser and you’ll be hitting the new IP location.

Linux

You can edit the hosts file in Linux directly on the command line.

1. Open a Terminal

2. Open the hosts file

Edit the hosts file by typing the following command:

sudo nano /etc/hosts

Type your sudo password when prompted.

3. Edit the hosts file

Your hosts file will already contain some default hostname entries (e.g. 127.0.0.1 localhost). Simply add in your custom entry for your domain onto its own new line right below the default lines. For example:

5.101.138.188    mywesbite.com

4. Save the hosts file

When you are done modifying your hosts file, press Ctrl+O to save the file.

Press enter when prompted for the filename, and then hit Ctrl+X to exit out of ‘nano’.

5. Flush the DNS cache

Typically, you will want to flush the existing DNS cache from your computer so that your host file changes can take effect immediately.

On Ubuntu, you can run:

sudo /etc/init.d/dns-clean start

Now load your site in your browser and you’ll be hitting the new IP location.

To reverse the process

Simply follow the instructions again and remove the line you added to the hosts file.

Important Note: While these directions are reliable, a little knowledge can be a dangerous thing. Do your research and get answers to any questions before editing any program files on your computer. We are not responsible any misuse of these instructions.

 


Was this answer helpful?

« Back