Check website performance using the hosts file
Often, when transferring a site to a new server, there is a need to check its operation from a new IP address before redirecting, so that the site does not idle with an error if something goes wrong. You can make such a check through the hosts file. The hosts file is a text file that contains a database of domain names and is used to translate them into host network addresses. By making a request through this file, we have priority over DNS servers and can open a site that is not directed to the server's IP address, but when the files are physically present there. Similar operations can be performed even with a non-existent domain.
Working with the hosts file on Windows
In order for you to be able to make changes to the file, for this open the Notepad program on behalf of the Administrator (via the right mouse button on Notepad). And then open the hosts file. On the Windows operating system, you can find this file along the path:
C:\WINDOWS\system32\drivers\etc\hosts
Or set write permissions. Click on the file with the right mouse button, go to the "Security" tab, select the group and click the "Edit" button.
Next, open the file with a text editor convenient for you, be it a standard Notepad. Enter at the end of the file the IP address of the server and the domain you want to check from the new server. When you save the file, open your browser and enter your website in the browser's address bar. In order to be sure that you opened the site from a new IP address, use the "Incognito" mode so that the cached content does not mislead you.
After checking the site, do not forget to delete or comment out the line with the pound sign "#", as shown in the example in the screenshot.
Working with the hosts file on Linux / MacOS
The file is located at /etc/hosts for Linux or /private/etc/hosts for MacOS. To make edits, you need to open it with an installed text editor and use the sudo command. Editors to modify: nano, mcedit, vim, emacs, gpedit.
The command is the following:
sudo nano /etc/hosts
Instead of nano, you can use an editor convenient for you - vim or mcedit. The sudo command is meant to run a command with privileged access, meaning that if you were running as root you wouldn't need to use it. We recommend that you use this particular command, since working as root requires you to think carefully. An example of the contents of the hosts file on MacOS and Linux is provided below. Add a line to the end of the file with the IP address of your server and the name of the domain.
Conclusion
All site checks are recommended to be performed in a new browser or from a secure window (incognito or private window). After checking the operation of sites, these edits in the hosts file must be commented out with a '#' sign or deleted.
In this article, we have shown you how you can check the operation of the site when moving to a new server or work with domain names while the DNS servers are being updated.
Check website performance using the hosts file Often, when transferring a site to a new server, there is a need to check its operation from a new IP address before redirecting, so that the site does not idle with an error if something goes wrong. You can make such a check through the hosts file. The hosts file is a text file that contains a database of domain names and is used to translate them into host network addresses. By making a request through this file, we have priority over DNS servers and can open a site that is not directed to the server's IP address, but when the files are physically present there. Similar operations can be performed even with a non-existent domain. Working with the hosts file on Windows In order for you to be able to make changes to the file, for this open the Notepad program on behalf of the Administrator (via the right mouse button on Notepad). And then open the hosts file. On the Windows operating system, you can find this file along the path: C:\WINDOWS\system32\drivers\etc\hosts Or set write permissions. Click on the file with the right mouse button, go to the "Security" tab, select the group and click the "Edit" button. Next, open the file with a text editor convenient for you, be it a standard Notepad. Enter at the end of the file the IP address of the server and the domain you want to check from the new server. When you save the file, open your browser and enter your website in the browser's address bar. In order to be sure that you opened the site from a new IP address, use the "Incognito" mode so that the cached content does not mislead you. After checking the site, do not forget to delete or comment out the line with the pound sign "#", as shown in the example in the screenshot. Working with the hosts file on Linux / MacOS The file is located at /etc/hosts for Linux or /private/etc/hosts for MacOS. To make edits, you need to open it with an installed text editor and use the sudo command. Editors to modify: nano, mcedit, vim, emacs, gpedit. The command is the following: sudo nano /etc/hosts Instead of nano, you can use an editor convenient for you - vim or mcedit. The sudo command is meant to run a command with privileged access, meaning that if you were running as root you wouldn't need to use it. We recommend that you use this particular command, since working as root requires you to think carefully. An example of the contents of the hosts file on MacOS and Linux is provided below. Add a line to the end of the file with the IP address of your server and the name of the domain. Conclusion All site checks are recommended to be performed in a new browser or from a secure window (incognito or private window). After checking the operation of sites, these edits in the hosts file must be commented out with a '#' sign or deleted. In this article, we have shown you how you can check the operation of the site when moving to a new server or work with domain names while the DNS servers are being updated.