How to Edit Your Hosts File in MAC OS

1. Open Terminal, which is in Applications, then the Utilities folder.


2. To be on the safe side, you should backup your existing host file, just incase.  Copy and paste the following command and hit return:


sudo cp /private/etc/hosts /private/etc/hosts-orig


3. After you have a backup copy, you can then edit your host file. To get started, copy and paste the following command and hit return:


sudo nano /private/etc/hosts


4. You will then be prompted your admin password for your Mac user.  Enter it just like you're logging onto your computer and press return.


5. This will bring up your host file which looks something like this:


Host Database

#

# localhost is used to configure the loopback interface

# when the system is booting. Do not change this entry.

##

127.0.0.1 localhost

::1 localhost

Below this, you will add your domain and IP address.  For example:

 Host Database

#

# localhost is used to configure the loopback interface

# when the system is booting. Do not change this entry.

##

127.0.0.1 localhost


::1 localhost

IP address  domain.com

IP address  www.domain.com



6. After you add your IP + domain press Control + X to exit nano and Y and press return to commit the changes.


7. Once this has been completed, you need to flush your local DNS by typing this command and pressing return:


dscacheutil -flushcache


After you do that, close out your open browsers, and re-open to view your website on the new server! 

Did you find it helpful? Yes No

Send feedback
Sorry we couldn't be helpful. Help us improve this article with your feedback.