How to Change Localhost File on Mac - DreamIT Host

Our Blog

How to Change Localhost File on Mac

Oct 06, 2020

How to Change Localhost File on Mac

Follow these steps to change localhost file on Mac:

 

1. Open Terminal.
How to Change Localhost File on Mac

 

2. Type the following command: sudo nano /etc/hosts, then press ‘Enter’.
How to Change Localhost File on Mac

 

3. This will request your password. Type in your account password, then press ‘Enter’.
How to Change Localhost File on Mac

 

4. This will show the contents of your local host file.
How to Change Localhost File on Mac

 

5. 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.
How to Change Localhost File on Mac

 

6. 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.
How to Change Localhost File on Mac


7. 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.
How to Change Localhost File on Mac

 

8. It will ask to confirm the file name to write the changes to. Press ‘Enter’ to save those changes.
How to Change Localhost File on Mac

#