Modifying the hosts file

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:
– Linux
– 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.

The entry should look like this
(Server IP followed by the website, preferably with or without www)

Windows 10 and Windows 8

  1. Press the Windows key to display the Start Menu
  2. Enter “Notebook” and find the editor in the search results
  3. Right click on Notebook and select “Run as Administrator”
  4. Open the C: \ Windows \ System32 \ Drivers \ etc \ hosts file
  5. 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).

Latest posts by Aleksandra (see all)
Junior administrator and consultant at Smarthost. She loves to travel, and in her spare time she is involved in photography and language learning.

Leave a Reply