Editing local hosts file on a Mac

A good cheat for viewing a website before it is live on a server is to add an entry to your Host file on your Mac. This file bypasses the DNS so you can view the site whilst it's still in development.


On MAC OSX

1. Open Terminal from Applications>Utilities>Terminal.

 

 

 

2. Open the hosts file in Terminal by entering:

$ sudo nano /private/etc/hosts

(you may need to remove the '$' if terminal reports "-bash: $: command not found").

 

3. Enter your Mac password if you have one. 

 

4. Use the arrow keys to navigate to the bottom of the list, and enter the IP Address of your server, hit the tab button, then input the url of your website. 

5. When finished, hit Control+O followed by ENTER/RETURN to save changes 

6. Now you can test your sites as if they were live. You may need to clear your browser cache and then browse to the domain.

Note: To go back to using the public DNS you need to revert the changes made to your local host file. To do this, do the exact same steps above, but remove the new entries you made, then save as detailed in step 5. You may need to clear your browser cache once again not ensure everything is fresh. 

NB: If you entered www.example.com in your host file, you'll need to browse to www.example.com.
Example.com would still show the current live site unless you also place this in the hosts file.

  • Email, SSL
  • 113 Users Found This Useful
Was this answer helpful?

Related Articles

Editing local hosts file on PC

A good cheat for viewing a website before it is live on a server is to add an entry to your Host...

Repair a MySQL database table

Occassionally you may get a database error that requires a repair to one of your database tables....

Restore from our Backup Service

If you have subscribed to this service, you can contact our support team for restores, or, if you...

Pointing a domain to your server

To get your domain hosting up and running you will need to add a DNS entry onto our Name...

Edit DNS Records on our Nameservers

You will first need to add the domain to our nameservers by following step 3 in the guide here:...