This article explains how to edit your local machine's hosts file so you can point a domain to a specific IP address.

This is useful when you want to access a site hosted on WP NET, prior to pointing the domain to the server with your domain registrar.

Once this is done, you will be able to access your site using the domain name (from your local machine only), whilst other visitors will see the server the domain registrar is pointing to. This allows you to work on your website, whilst leaving an existing website (or holding page) in place for public visitors.

To check what IP address a given domain name is pointed to perform an 'A' record search using What's My DNS: www.whatsmydns.net.


Hosts File Location

The location of the hosts file varies, depending on your operating system, common locations are:

Windows 7 / 8 / 10

%systemroot%\system32\drivers\etc\

For example: C:\Windows\System32\Drivers\etc

MacOS X

/private/etc/

Editing Your Hosts File

IMPORTANT: You will need administration rights on your machine in order to edit the hosts file.

For detailed instructions, see:

Windows 7 / 8: helpdeskgeek.com/windows-7/windows-7-hosts-file
Mac OS X: www.tekrevue.com/tip/edit-hosts-file-mac-os-x

For example, to point the domain mywebsite.co.nz to the IP address 123.123.123.123, you would add the following to an empty line in your hosts file.

123.123.123.123    mywebsite.co.nz

To get the IP address for the WP NET server your site is hosted on, please refer to the email you received when our hosting was activated - your server's IP address is included in this message. Alternatively, you can login to the Plesk Panel and your IP address will be displayed on the Websites & Domains page.

Once you have edited and saved the hosts file, you should restart your browser. If you still can't access the domain, you may need to flush your local machine's DNS cache.


Flush the DNS Cache on Windows 7 / 8 / 10

Open a command prompt:

  1. Click the Start button on the Windows task bar
  2. In the search bar, enter cmd and press enter - a command prompt window will open

In the command prompt, run the following command:

ipconfig /flushdns

Flush the DNS Cache on MacOS

OS X Yosemite

Use the following Terminal command to reset the DNS cache:

sudo discoveryutil mdnsflushcache

OS X Mavericks, Mountain Lion, and Lion

Use the following Terminal command to reset the DNS cache:

sudo killall -HUP mDNSResponder

Mac OS X v10.6

Use the following Terminal command to reset the DNS cache:

sudo dscacheutil -flushcache

Final Notes

It is important to note that once you've edited your hosts file to point to our server, only your local machine will be "aware" of the correct IP address. Other web visitors -- and external web services -- will still be directed to which ever IP address is set in your domain's hosted DNS zone. Keep this in mind as you work on your site with a modified hosts file -- licensing plugins and themes and working with external web services may not work as expected.

And lastly, once you have completed your site and pointed your live domain to the server, be sure to edit your hosts file again and remove the added entry.

Was this answer helpful? 30 Users Found This Useful (169 Votes)