One of the most important parts of the migration process is testing. During this time, we ask the site owner to go through and carefully test pages, links and make sure that everything is working the way that it should before changing the DNS and making the site live on your new server.
Once our Migration team has completed the validation of your site, they will notify you that it is time for you to edit your DNS Hosts File and begin testing. Your computer's hosts file is one of the most powerful tools available for you to view and test a site on the new server while your site is still available to the world on the other. By editing the hosts file, you can ensure that everything on the site works as expected before you update the DNS records and that your site visitors won't be affected by any potential issues related to different server environments.
Editing your DNS Hosts File is a simple process. In most cases, you will need administrative privileges to edit the DNS host file. These instructions are specific to your operating system:
- Your Host Files are located in the etc directory. You can view them by using the command:
- Your Host Files will appear. In this case, the first three entries are defaults used to configure the local network interface. Any custom entries will go at the bottom of this file.
## # Host Database # # localhost is used to configure the loopback interface # when the system is booting. Do not change this entry. ## 127.0.0.1 localhost 126.96.36.199 broadcasthost ::1 localhost hosts (END)
- Edit your host file manually with vi, vim, or nano, or append the new entry directly from the command line. If your migration involves multiple IP addresses, you will have one line for each IP address, regardless of how many domain names share it.
- To use vim, open a terminal and enter the command:
sudo vim /etc/hosts
- Enter your password if prompted.
- Move your cursor to the end of the hosts file using your arrow keys and enter the entry given to you by the Migration specialist. To save the file hit the escape key and type the following command:
- To append the entry to the existing file, you can use one command to substitute your server's IP address and domain name for the ones in this example:
echo "188.8.131.52 test.com www.test.com | sudo tee -a /etc/hosts >/dev/null
- and enter your password.
- Many Ubuntu and Debian-derived distributions use:
sudo service dns-clean restart
- Other Linux distributions using Name Service Caching Daemon may need to use:
sudo service nscd restart, sudo systemctl restart nscd.serviceor
nscd -l hosts
- The host file is located at /private/etc/hosts for Mac OS. If your migration involves multiple IP addresses, you will have one line for each IP address, regardless of how many domain names share it.
- Click on your Applications icon, then search for "Terminal." Click on the Terminal to launch the CLI.
To edit the file manually:
- Enter the following command in Terminal:
sudo nano /private/etc/hosts
- Enter the password when prompted and press Enter to authenticate and open the file
- To add the entry given to you by the Migration specialist:
- Use your arrow keys to navigate to the bottom of the file
- Type in (or paste) the IP address and website name you intend to redirect
- Press Control+O to save the file
- Press Enter to overwrite the existing file
- To exit, press Control+X
- Enter the following command in Terminal:
To append the entry:
- In the command line, use the following command:
echo "184.108.40.206 test.com www.test.com" | sudo tee -a /private/etc/hosts >/dev/null
- When prompted, enter your password to complete the command.
Flush the DNS cache so you don't have to log out and log back in for changes to take effect. You can use this command:
dscacheutil -flushcache; sudo killall -HUP mDNSResponder
The hosts file is located at: C:\Windows\System32\drivers\etc\hosts.
- First, open an elevated command prompt:
- In Windows 8 and higher, use the keyboard shortcut Windows key + x to access the Power Users menu, then select the Command Prompt (Admin).
- In previous Windows versions:
- Type "command" into the search field at the bottom of the Start menu.
- Right-click on the cmd.exe icon
- Select Run as Administrator.
If All Else Fails
There is a third-party website which will allow you to preview and test your website on a different IP address. Hosts.CX is a free web-based service that will help you test on a per site basis.
When visiting https://hosts.cx, you will be asked to provide your server address and website name. Click the Get My Testing URL link and you will be provided with a shortened URL to open and test your site on the new server.