NOTE: If you need to make a hosts file modification in Windows, please see our Modifying Your Hosts File article instead.

Like many Unix-based and Unix-like operating systems, it is possible to change the hosts file on your Mac to manually set a domain to a certain server.

Changing this file will override any DNS settings you might receive from your ISP, so this is a good way to test a site before you have transferred the domain from your old host to us.

Modifying the hosts file in Mac OS X 10.2 and later is a pretty easy task, but it must be done as the “root” user in the terminal. This change will point ONLY your Mac to your site with us. It will not affect other computers' access to your site at your former host.

Steps to editng your hosts file

  1. Open the Mac's Terminal.
  2. You may either type Terminal on the Spotlight, or by going into Applications -> Utilities -> Terminal.

  3. Open the hosts file for editing.
  4. In the terminal window you just opened copy/paste the command string below, and press return.

    sudo nano /private/etc/hosts

    You'll be prompted to enter your Mac user's password. NOTE: you won't see the cursor move. This is normal, so press return when done.

  5. Edit the hosts file by adding these two lines to the bottom of the file.
  6. SERVER_IP_ADDRESS domain.com
    SERVER_IP_ADDRESS www.domain.com

    For example, it should look like:

    67.199.146.25 domain.com
    67.199.146.25 www.domain.com

    Make sure that there is a space between the IP and the URL! Otherwise, the rule will not work.

    Be sure to place domain.com with your actual domain name. If you're not sure which IP address to use, please contact our Support Department for further assistance.

  7. Save save your changes by pressing control-o on your keyboard then return to accept the filename. Exit the editor by pressing control-x. This takes you back to the terminal screen.
  8. You may need to flush your Mac's DNS cache, so copy/paste the below command string into terminal, and press return.
  9. dscacheutil -flushcache

    This completes the hosts file modification, so you should now be able to see your site here with us using your domain in your browser's address bar.

    When testing is complete you may undo these changes by repeating the steps above but removing the information entered in step 3.

    If you are running a Windows based system, please  see our general hosts file article.

Did you find this article helpful?

We value your feedback!

Why was this article not helpful? (Check all that apply)
The article is too difficult or too technical to follow.
There is a step or detail missing from the instructions.
The information is incorrect or out-of-date.
It does not resolve the question/problem I have.
How did you find this article?
Please tell us how we can improve this article:
Email Address
Name

new! - Enter your name and email address above and we will post your feedback in the comments on this page!

Related Questions

Here are a few questions related to this article that our customers have asked:
Ooops! It looks like there are no questions about this page.
Would you like to ask a question about this page? If so, click the button below!
Ask a Question
n/a Points
2014-05-07 11:50 am

In step #4 when I press control-x nothing happens, so I cannot clear my cache per step 5.

Staff
9,162 Points
2014-05-07 11:54 am
Within the nano text editor, ctrl+x will indeed quit the exitor that is running inside the terminal window. Be sure that you are pressing ctrl+x and not command+x.
n/a Points
2014-06-10 10:30 am

I am stuck on step 4 as well. I pushed both control-x and control+x and it wont go back. So I'm not sure it saved. 

Staff
9,162 Points
2014-06-10 10:36 am
Ctrl+c will also kill the process as well.
n/a Points
2014-06-10 10:50 am

I tried the control (+/=) bottom and c. And still do nothing. I guess what should i be looking for because All i'm seeing is the host database. 

Staff
9,162 Points
2014-06-10 1:22 pm
Based on your reply, it sounds like you're trying to press 3 different buttons at one. To clarify, press the control and c buttons at the same time, and not any additional keys.
n/a Points
2014-09-24 11:37 pm

you are missing a step between contrl-o and control-x you need to hit enter

Post a Comment

Name:
Email Address:
Phone Number:
Comment:
Submit

Please note: Your name and comment will be displayed, but we will not show your email address.

7 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?

Search

Ask the Community!

Get help with your questions from our community of like-minded hosting users and InMotion Hosting Staff.

Current Customers

Chat: Click to Chat Now E-mail: support@InMotionHosting.com
Call: 888-321-HOST (4678) Ticket: Submit a Support Ticket

Not a Customer?

Get web hosting from a company that is here to help. Sign up today!