Skip to content

Managing a hosts file

Modifying a hosts file allows a site to be tested with a different domain before the global DNS system has been modified or updated to point to VIP. This modification only affects a user’s local computer, and will need to repeated on any other devices that are used for testing.

A hosts file consists of IP addresses listed against domains. For example:

192.0.66.2 example.com
192.0.66.2 wpvip.com

In the above example, example.com and wpvip.com are modified to point at 192.0.66.2, a VIP IP address.

To determine the IP address for a VIP application, run the command host against an application’s convenience domain. For example:

$ host example-com.go-vip.net
example-com.go-vip.net has address 127.0.0.1
example-com.go-vip.net has address abcd:efgh:ijkl::c000:1234

All modern operating systems make use of a hosts file, but the process for modifying the file varies slightly for each system.

If the changes are not reflected immediately, clear the browser cache and try visiting the site again. Remember to revert all of the changes once testing is complete.

macOS and Linux

  1. Open a Terminal window.
  2. Enter the following command to open the hosts file in a text editor: sudo nano /etc/hosts.
  3. Enter the root password at the prompt.
  4. Add the IP address and domain needed for testing.
  5. Press Control+X then type y at the prompt to save the changes.

Windows

  1. Press the Windows key.
  2. Type Notepad in the search field.
  3. In the search results, right-click Notepad and select Run as administrator.
  4. From Notepad, open the following file: c:\Windows\System32\Drivers\etc\hosts .
  5. Add the IP address and domain needed for testing to the file and save the changes.

Last updated: August 03, 2023

Relevant to

  • Node.js
  • WordPress