Skip links

How To Change Local Host File on Mac

    1. Open Terminal.

 

  • Type the follow command: sudo nano /etc/hosts, then press ‘Enter’.

 

 

  • This will request your password. Type in your account password, then press ‘Enter’.

 

 

  • This will show the contents of your local host file.

 

 

  • Underneath the text ::1 localhost, type in the IP address of your server and the name of your website. Syntax as follows: (IP Address) (Domain Name)
    Always type two entries for the one domain name, ie. www.example.com followed by example.com.

 

 

  • You can add # in front of your entry. This will turn the text into a string and won’t be read by the system.
    Very convenient to switch between the server you are working on and the server your domain is pointing to.

 

 

  • Once you have typed in your entries, press ‘Ctrl and X’ at the same time to exit the file. It will then request if you wish to save your changes. Press ‘Y’ for Yes, ‘N’ for No, or ‘Ctrl and C’ to Cancel.

 

 

  • It will ask to confirm the file name to write the changes to. Press ‘Enter’ to save those changes.