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 and 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 37SOLUTIONS 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 hosts file. These instructions are specific to your operating system:
Warning: |
Do not remove or modify any existing local entries in your hosts file. You will only be adding a new line or lines at the bottom of the file for testing, then remove the lines once testing is completed. |
Linux
- Your Host Files are located in the etc directory. You can view them by using the command:
cd /etc
-
Then type:
less hosts
- 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 123.123.123.123 broadcasthost ::1 localhost hosts (END)
- Edit your hosts 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 edit the file, use the i key to insert text. To save the file hit the escape key and type the following command:
:wq
- 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 "1.1.1.1 test.com www.test.com | sudo tee -a /etc/hosts >/dev/null"
- and enter your password.
- To use vim, open a terminal and enter the command:
- Before you exit the terminal, you should flush your local DNS cache (see Flushing Your Local DNS Cache for directions) so you don't have to log out and log back in for changes to take effect. The command can vary depending on your specific distribution and version.
- 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.service
ornscd -l hosts
- Many Ubuntu and Debian-derived distributions use:
Mac OS X
- The hosts 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
To append the entry:
- In the command line, use the following command:
echo "1.1.1.1 test.com www.test.com" | sudo tee -a /private/etc/hosts >/dev/null
- When prompted, enter your password to complete the command.
- Enter the following command in Terminal:
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
Windows
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.
- Enter the following command:
notepad C:\Windows\System32\drivers\etc\hosts
- Add the line your Migration specialist indicated you to use at the end of your hosts file, then save and close the file. If your migration involves multiple IP addresses, you will have one line for each IP address, regardless of how many domain names share it.
- The last step is to flush your DNS cache so you don't have to log out and log back in for the changes to go into effect. If you need help flushing your DNS cache, see our article Flushing Your Local DNS Cache.
ipconfig /flushdns
Note: |
When copying and pasting the DNS hosts file given to you by the Migration team, Windows 10 does allow for keyboard shortcuts. All other versions of Windows will need to use the right-click method of copy/paste. If you prefer, you also can locate Notepad, right-click its icon to select “Run as Administrator”, then open your hosts file (at C:\Windows\System32\drivers\etc) in Notepad. With this method, you will need to change “Text Documents (*.txt)” in Notepad’s file browser to “All files” to see the hosts file, and you still will need to open a command prompt to flush your DNS cache as described in Step 6. |
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.
Note: |
37SOLUTIONS has no affiliation with Hosts.CX and does not offer support for testing using the site. |
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.
Warning: |
While this is a helpful tool, certain functions, such as CAPTCHA may not work as expected. Do not transmit any sensitive data such as login information or passwords while testing using this service. |
Comments
0 comments
Please sign in to leave a comment.