All Collections
Useful Tools and Tips
Adjusting your ‘hosts’ file
Adjusting your ‘hosts’ file
Scott avatar
Written by Scott
Updated over a week ago

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 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 use case:

 Charlie just signed up for a brand new VPS service here at BigScoots and requested us to migrate 30 of his websites onto it. Many of these websites are his client’s sites and he is nervous about the big move after years with the previous host. By adjusting his ‘hosts’ file locally, Charlie is able to browse all 30 of these websites before changing the DNS to point away from his old host and to BigScoots. This allows Charlie the ability to confirm everything was migrated properly without having all the traffic forwarded to the new server before he's able to check it for issues — which of course there were none! 

 

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 Charlie’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, completely close out of your browser, reopen and browse to the domain used in your hosts file.

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 uneditable 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 BigScoots and ask for clarification. Keep to the steps listed above, ask if you have any questions, and you’ll be just fine! 

Did this answer your question?