The hosts file allows you to overwrite the domain’s DNS for a specific machine (computer, server, etc.). This option is helpful when you are migrating data between servers. Before changing the DNS of the domain on which the moved page is available, you can modify the hosts file to see if it works correctly from the new server.
Entries in the file are taken into account before DNS queries. This means that due to changes in the hosts file, you can get a reference directly to any server without querying DNS servers.
How to modify the hosts file?
This article describes how to modify the file on the following systems:
– MacOS X
– Microsoft Windows 10, Windows 8, Windows 7, Windows Vista
Linux and MacOS X
Open a terminal
Type the following command to open the hosts file in a text editor:
sudo nano / etc / hosts
Enter the password required to log in as an administrator.
Make the necessary changes to the file.
Use Ctrl + O and then Enter to save the changes.
Press Ctrl + X to exit the editor.
Windows 10 and Windows 8
- Press the Windows key to display the Start Menu
- Enter “Notebook” and find the editor in the search results
- Right click on Notebook and select “Run as Administrator”
- Open the C: \ Windows \ System32 \ Drivers \ etc \ hosts file
- Make changes and save the file
Please note that if the page was already opened before the change, you should clear the browser cache or open the page in another browser, alternatively using a different network (cache can also be stored at the router level).