InMotion Hosting Support Center
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 editing 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.

    For example, it should look like:

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

    Be sure to place 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

    You may have to add sudo to this command, for example:
    sudo 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.

Support Center Login

Social Media Login

Social Login Joomla

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.

11,186 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. 

11,186 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. 

11,186 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

n/a Points
2014-11-20 7:40 pm
It would help if u added sudo in front of the dscacheutil -flushcache command for flushing the DNS since it wont work without sudo added to it. some people are new to linux commands so it would help if it is added.
26,229 Points
2015-02-19 2:38 pm
Hello Muhammad,

Thank you for your helpful suggestion. I have added this to the article as recommended.

We welcome any additional suggestions you may have.

Thank you,
n/a Points
2015-02-19 8:40 am

I followed instructions. but How can I see the website????  You did not explain it here.  Is it locahost/  Please advise.

26,229 Points
2015-02-19 2:26 pm
Hello Rachel,

Thank you for your question. After changing your hosts file, you will then navigate to your domain.

For example, if you create:

You will test by navigating to:

Be sure to replace with your actual domain name, and replace the with your actual shared IP address.

Thank you,
n/a Points
2015-03-04 8:45 pm
brilliant thanks for a well detailed easy to understand process for a newbie to this backend stuff much appreciated
n/a Points
2015-04-16 4:48 pm

I edited my hostname successfully, but now only see:

index of/

  • artist/
  • cgi-bin/

on the test home page. What am I missing?

26,229 Points
2015-04-16 5:12 pm
Hello Pamela,

Thank you for your question. This seems like you are resolving to your server, but there is no website in the root folder.

Instead, it looks like your root folder has a folder named artist, that may contain the files. Most likely this folder needs to be moved up a level. In other words, move the content of the /artist folder up 1 folder.

We have a helpful article that explains What directory you should put your files in.

Thank you,
n/a Points
2015-04-16 5:23 pm

Thanks, and yes, the folder /artist does contain the files. I don't recall creating a folder called artist, so not sure where that came from. That folder doesn't appear anywhere among the files and folders I uploaded via FTP. Hmmm.

Is there an easy way to move the files from /artist to the /public_html directory?

26,229 Points
2015-04-16 5:29 pm
Hello Pamela,

Thank you for contacting us. Yes, there are several ways to move files on your server.

I recommend using FileZilla, which is covered in the guide.

Thank you,
n/a Points
2015-04-16 5:35 pm

Okay, that was easy. Test site works fine now. Thanks.

n/a Points
2015-07-19 4:13 am

Excellent - thanks!!

n/a Points
2015-09-01 11:07 am

I did this the other day and it worked fine. Today, when I went back in to do some more work on the site, I couldn't get to the wp-login/admin page. 

I "undid" everything, and then re-entered it all, but still no luck. Any suggestions?

10,077 Points
2015-09-02 12:01 am
Hello Bike2n,

What domain/IP are you trying to access so we can test it from our side to make sure it is not something with the server hosting your website. Have you made any changes to the .htaccess or the URL settings within WordPress?

Best Regards,
TJ Edens
n/a Points
2015-10-30 4:48 am


I have somehow become stuck in the terminal when trying to remove the information.  When pressing ctrl x nothing happens.

Also am I supposed to remove the information or do I just repeat the sequence leaving out point 3?


n/a Points
2015-10-30 6:12 am


I used your instructions which worked are are really great, however now that I want to remove the info in the terminal it I am faced with the issue of when pressing ctrl x nothing happens and also, do I try delete the info or do I just re enter all instuctions, leaving out instruction 3?


11,946 Points
2015-10-30 8:18 am
You can simply edit the file, and place a # symbol in front of the line. This will render it inoperable as the system will read the line as a comment.
n/a Points
2015-10-30 10:08 am

Thanks Timothy,

It would appear that works.



35,822 Points
2015-10-30 10:13 am
Hello Tania,

It sounds like you have it resolved. Remember that "nano" is an editor function within the terminal. The changes you make in the file don't apply until AFTER you have saved the file. You can always open up a second terminal window and type nano -help, then click hit enter. This will bring up the commands you can find on using nano. Hope that helps! If you have any further questions or comments, please let us know.

Arnel C.
2016-02-19 2:25 pm
I can't get past the control O part -- a navigation window appears. Am I missing something? My machine is currently running OS 10.11.3 El Capitan
10,077 Points
2016-02-20 3:34 am
Hello Chrismay99,

Holding down control and hitting o should save the file then control + x should exit the file. Are you getting an error trying to do this?

Best Regards,
TJ Edens
n/a Points
2016-09-09 4:12 pm

OK, did this, now how to I undo it so I can view the site live?...I'm on a mac

6,526 Points
2016-09-09 5:57 pm
Follow the same steps again to access the file. Then you can erase the line you added. This will deactivate the modification. Make sure to save the file. Also, I recommend you clear your browser cache to make sure you have reloaded the active site.
n/a Points
2016-11-29 2:52 am

When I'm testing the website, is there a way to check if it's testing from the new webhost or still using the old one?

6,526 Points
2016-11-29 10:06 am
There are many DNS lookup services on the web you can search for, or you can use our DNS tool.

Post a Comment

Email Address:
Phone Number:

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

33 Questions & Comments

Post a comment

Back to first comment | top

Need more Help?


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:
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!