How to edit your Host file Print

  • 3

The purpose of editing your HOST file is to tell your computer which IP address a domain name should be associated with. This is often before your domain name is updated to point to a particular IP address. e.g. moving web hosts or for web development reasons. If after making these changes you still cannot see the correct IP address in your browser then please see the following knowledge based article: How to Clear the DNS Resolver Cache in Chrome, Edge, Firefox, and Opera

 

Windows Computers

1) Right-Click Notepad and Choose "Run as Administrator"

2) Use the File Open dialog in Notepad to go to "C:\Windows\System32\Drivers\etc"

3) You will need to change the file type setting in the Open dialog to "*.*".

4) Click on "HOSTS" and open the document.

5) Edit the document per the instructions like this:

10.10.10.10   domain.com
10.10.10.10   www.domain.com

* Replace IP Address with the new IP address from your DNS settings.

6) Save and open in a browser. (you might need to clear the browser cache still).

NOTE: once DNS has propagated you will want to remove these entries from your computer to avoid future problems.

 

Linux

  1. Open a terminal window.
  2. Open the hosts file in a text editor (you can use any text editor) by typing the following line:

    sudo nano /etc/hosts
    
  3. Enter your domain user password.

  4. Make the necessary changes to the file.

    10.10.10.10   domain.com
    10.10.10.10   www.domain.com

    * Replace IP Address with the new IP address from your DNS settings.

  5. Press Control-x.

  6. When asked if you want to save your changes, answer y.



Mac OS X 10.0 through 10.12

Mac OS X 10.0 through 10.1.5

  1. Open /Applications/Utilities/NetInfo Manager.

  2. To allow editing of the NetInfo database, click the padlock in the lower-left corner of the window.

  3. Enter your domain user password and click OK.
  4. In the second column of the browser view, select the node named machines.

    The third column contains entries for -DHCP-broadcasthost, and localhost.

  5. In the third column, select localhost.
  6. From the Edit menu, select Duplicate. (The quickest way to create a new entry is to duplicate an existing one.)

    A confirmation alert appears.

  7. Click Duplicate.

    A new entry called localhost copy appears, and its properties are shown below the browser view.

  8. Double-click the value of the ip_address property and enter the IP address of the other computer.

  9. Double-click the value of the name property and enter the hostname you want for the other computer.

  10. Click the serves property and select Delete from the Edit menu.
  11. From the File menu, select Save.

    A confirmation alert appears.

  12. Click Update this copy.

  13. Repeat steps 6 through 12 for each additional host entry that you want to add.
  14. From the NetInfo Manager menu, select Quit.

    You do not need to restart the computer.



Mac OS X 10.6 through 10.12

  1. Open Applications > Utilities > Terminal.
  2. Open the hosts file by typing the following line in the terminal window:

    sudo nano /private/etc/hosts
    
  3. Type your domain user password when prompted.
  4. Edit the hosts file and add your new mappings on the last line.

    10.10.10.10   domain.com
    10.10.10.10   www.domain.com

    * Replace IP Address with the new IP address from your DNS settings.

  5. Save the hosts file by pressing Control+X and answering Y. Then press ENTER.

  6. Make your changes take effect by flushing the DNS cache with the following command:

    dscacheutil -flushcache
    

The new mappings should now take effect.

 


Mac OS 10.12 - 12.5 (Monterey)

  1. Open Applications > Utilities > Terminal.
  2. Open the hosts file by typing the following line in the terminal window:

    sudo nano /private/etc/hosts
    
  3. Type your domain user password when prompted.
  4. Edit the hosts file and add your new mappings on the last line.

    10.10.10.10   domain.com
    10.10.10.10   www.domain.com

    * Replace IP Address with the new IP address from your DNS settings.

  5. Save the hosts file by pressing Control+X and answering Y. Then press ENTER.

  6. Make your changes take effect by flushing the DNS cache with the following command:

    dscacheutil -flushcache
    

The new mappings should now take effect.


Was this answer helpful?

« Back