Editing your hosts file to preview your website

Overview:

Editing the "hosts" file on your computer allows you to bypass DNS queries and resolve a specific domain to an IP address on your local machine. This guide explains how to edit the "hosts" file on Windows, Mac OS X, and Linux.

This can be incredibly useful when you are building or testing a website but do not want to make changes to your existing DNS to point public traffic to your work in progress.  Such "hosts" files are present in all operating systems, and the method of editing them is different in each.

Windows method:

  1. Open the Run window by pressing Windows+R.

  2. Type "notepad c:\Windows\System32\drivers\etc\hosts" and run as an Administrator by pressing Ctrl+Shift+Enter.

  3. Add a new line to the bottom of the hosts file with the IP address you wish your domain to resolve to, followed by the domain itself. Separate the IP address and domain name with a space or tab.

    1. For example, “123.456.78.9 domain.com.au”

  4. Save the file and go to your domain in a browser. You may need to load it in a new browser window or clear your browser cache to ensure you are loading the correct server.


Mac OS X method:

  1. Open Terminal app by going to "Applications > Utilities > Terminal".

  2. Type "sudo nano /private/etc/hosts" into the Terminal window and input your password when prompted.

  3. Add a new line to the bottom of the hosts file with the IP address you wish your domain to resolve to, followed by the domain itself. Separate the IP address and domain name with a space or tab.

    1. For example, “123.456.78.9 domain.com.au”

  4. Save the file with Command+O, then exit Nano with Command+X.

  5. Go to your domain. You may need to load it in a new browser window or clear your browser cache to ensure you are loading the correct server.


Linux method:

  1. Open the terminal on your Linux operating system.

  2. Type "sudo nano /etc/hosts" into the Terminal window and input your password when prompted.

  3. Add a new line to the bottom of the hosts file with the IP address you wish your domain to resolve to, followed by the domain itself. Separate the IP address and domain name with a space or tab.

    1. For example, “123.456.78.9 domain.com.au”

  4. Save the file with Ctrl+O, then exit Nano with Ctrl+X.

  5. Go to your domain. You may need to load it in a new browser window or clear your browser cache to ensure you are loading the correct server.



Can't find what you're looking for?

Create or manage support tickets directly with Micron21

You will need to register a new account if this is the first time lodging a ticket.

If you have previous lodged a ticket either online, email or over the phone you will already have an account. Please reset your password, if you have not logged into the support portal before.

Lodge a ticket Manage existing tickets

Need to send us information securely? Use our Escrow service here

Need more advanced support?

Micron21 provides a comprehensive approach to customer care that starts with a base 24/7 support that is included free with every service we offer - there are no charges to enjoy a basic level of support with Micron21 and you are not restricted in how you contact us to receive assistance any time of day or night.

For those who require more advanced support though, our Customer Care plans and Ad-Hoc support are designed to completely remove the complexity of IT management - from taking full responsibility for your entire infrastructure or tailoring a custom approach, we have the capability and know-how.

 

If you've organised remote assistance from Micron21, click here to connect

Sign up for the Micron21 Newsletter