ADJUSTING YOUR 'HOSTS' FILE

Overview

Adjusting your ‘hosts’ file allows you (just you) to override the DNS for a particular domain on that particular machine. While it does have other uses, the main reason you would want to adjust your ‘hosts’ file is to test your website after a migration but prior to adjusting your DNS at your registrar and pushing all traffic to the new server to check for potential issues from the migration.

Example case:

Susan just signed up for a brand new Dedicated server and requested us to migrate 40 of her websites onto it. Many of these websites are her client’s sites and she is nervous about the big move after years with the previous host. By adjusting her ‘hosts’ file locally, Susan is able to browse to all 40 of these websites before changing the DNS to point away from his old host and to Greenix360. This allows Susan the ability to confirm everything was migrated properly without having all the traffic forwarded to the new server before she's able to check it for issues.

How to adjust your ‘hosts’ file on Windows 10 and Windows 8

  1. Press the Windows key
  2. Browse to ‘N’ and Notepad under ‘All Apps’
  3. Right click Notepad and select ‘Run as administrator’
  4. While in Notepad, select File > Open > and browse to c:\windows\system32\drivers\etc\hosts
  5. Now that you’re in the ‘hosts’ file, you can specify as many adjustments as you’d like per line. As an example, the below adjustment would force www.yourdomainA.com to point to the IP address 123.123.123.123 rather than the IP address the DNS is currently pointing to (in the earlier example, Charlie’s old host). In the below example you can see that we also wanted to bind 144.144.144.144 to www.yourdomainB.com and it was done on a separate line. Please also note it is important to always type your domain out twice, once with and once without the ‘www.’

123.123.123.123 yourdomainA.com www.yourdomainA.com
144.144.144.144 yourdomainB.com www.yourdomainB.com

Note: If you are wanting to swap between IPs quickly, you can include a ‘#’ at the beginning of a line to comment it out. In the below example, www.yourdomainA.com is still pointing to Susan’s old server, and www.yourdomainB.com is pointing to the new server.

#123.123.123.123 yourdomainA.com www.yourdomainA.com
144.144.144.144 yourdomainB.com www.yourdomainB.com

   6. As a final step, save the file and clear your browser cache.

 

How to adjust your ‘hosts’ file on Windows 7 and Vista

  1. Select Start > All Programs > Accessories
  2. Search for ‘Notepad’
  3. Within the results, right click Notepad and select ‘Run as administrator’
  4. Steps 4, 5 and 6 are identical to the Windows 10 and Windows 8 example

 

How to adjust your ‘hosts’ file on Linux

  1. Begin by opening a terminal window
  2. Open the ‘hosts’ file in a text editor of your choice by typing the below command:sudo nano /etc/hosts
  3. Enter your domain username and password
  4. Steps 4, 5 and 6 are identical to the Windows 10 and Windows 8 example
  5. Press control + x and save your changes

 

How to adjust your ‘hosts’ file on MAC OS X

  1. First we must locate the hosts file. To do so open Finder and within the menu bar select Go > Go to Folder. In the text box, type or paste the following:/private/etc/hosts
  2. In the window that just appeared, drag the ‘hosts’ file out of the Finder window and place it on your desktop. This will now allow us to freely edit the otherwise un-editable file.
  3. Double click the ‘hosts’ file that is now located on your desktop and open it in the text editor of your choosing (MAC’s default TextEdit works very well).
  4. Edit the ‘hosts’ file as outlined in the above Windows 10 and Windows 8 example (steps 5 and 6)
  5. Once edited and saved, you must place the ‘hosts’ file back in its original location:/private/etc
  6. If you still have the Finder window open you can simply drag and drop it back, if you’ve closed the Finder window simply use Finder > Go > Go to Folder (as outlined in step 1)
  7. After you’ve dragged and dropped the edited ‘hosts’ file into its original location it will ask you what to do with the ‘hosts’ file you’re overwriting. Simply select Replace and enter your administrative username and password (if prompted) to confirm the overwrite – and you’re done!

 

General Note: Please keep in mind that if you’re not familiar with editing system protected files this may seem like an extra administrative step that you may not feel comfortable with. Please know that editing your ‘hosts’ file is a very common procedure and can be a very useful tool for you to identify issues ahead of time. If you are the least bit confused with the above steps please never hesitate to open up a ticket with Greenix360 and ask for clarification. Keep to the steps listed above, ask if you have any questions, and you’ll be just fine!

  • 161 Users Found This Useful
Was this answer helpful?

Related Articles

LEAVE YOUR OLD HOST AND MOVE TO GREENIX360

Some Pre-Move Tips There are a few things you need to think about as you prepare to leave your...

General Info & Getting Started

Welcome to Greenix360!  Congratulations on signing up for a hosting account with us. Step 1:...

CLEAR YOUR BROWSER CACHE

The browser's cache temporarily stores images, scripts, and other parts of websites you visit in...

CREATE A LANDING PAGE OR ONE-PAGE SITE

Also known as a landing page or an under-construction page, a one-page site is the perfect...

DIFFERENCE BETWEEN CPANEL AND WHM

The Web Host Manager (WHM) is the account management panel that allows the hosting provider to...