Modifying Your Hosts File


This guide will provide a method of viewing/testing a domain on Rochen’s servers without actually changing that domain’s global DNS over to Rochen’s network on both Windows and Mac OSX. Typically, this type of functionality is gained through using Apache’s mod_userdir, but this is actually a highly ineffective approach for serious development and testing.

The reason the above method is ineffective is due to the well-documented compatibility issues between Apache’s mod_userdir and mod_rewrite. Often, in order to properly test an application, the application’s URL will need to be changed to the mod_userdir temporary URL (, which can cause unexpected and unnecessary complications.

The preferred alternative is modify your local hosts file. By modifying your hosts file properly, you can point your domain to a specific IP address (i.e. the one assigned to your Rochen hosting account) without having to defer to your router/network or on an external DNS resolver to inform your machine of the IP address of your domain. This means that if you make your modifications correctly, you can view your website in your browser, using your normal domain name, without actually affecting the global DNS of your domain whatsoever.


Firstly, to edit your hosts file on Windows, you will need to open a text editor (Notepad will suffice here) as an Administrator:

You must run Notepad as an Administrator or you will not have sufficient permission to modify the hosts file, which is write-protected for any user below Administrator by default. Once you have Notepad running under the Administrator account, open the following file:


Once your hosts file is open, you will see instructions for composing entries, along with a few examples.

You will want to add your website’s IP address (contact Rochen support if you do not have this information) and your domain name at the bottom of the file, as shown in the following screenshot:

Save the file.

Once saved, we will need to clear out your DNS resolver cache, as your computer will likely have the old IP cached for your site’s DNS and will not actually consult the hosts file in order to find it. To clear your DNS resolver cache, cPanel has a great guide located here.

You may now access your domain from your Rochen server.


The easiest way to make modifications to the host file on OSX is via the Terminal. To open your terminal, you will want to perform the following:

1. Click the Spotlight icon in the top-right of your desktop (magnifying glass)

2. Type: terminal

3. Press: Enter

If you completed the first two steps, you should now see this in the upper right-hand corner of your screen:

Select “Terminal” and press “Enter.” You will now want to execute the following command to open your hosts file with the nano text editor:

sudo nano /private/etc/hosts

An example can be seen below:

You will be prompted for your password (the same one you use to login to your Desktop). Identical to the Windows host file, you simply add your IP address and domain, as pictured below:

To save your changes:

Press CTRL+X
Press “y”

You will need to flush your DNS resolver cache in order to ensure that these changes are honored by your next request for your domain. To do this, please see the following cPanel article, located here

Updated on May 29, 2023

Was this article helpful?

Related Articles

Need Support?
24/7 support is available through the My Rochen portal.