How to test your website before updating the nameservers

We get this question very often. Clients asking us how to test their websites before changing the nameservers. One method is by using the hosts file. This file has no extension and is present on Windows, Linux and Mac systems. It links hostnames to IPs.

The idea is to temporarily link your site domain example.com to the new server IP.

On Windows the file location is c:\Windows\System32\drivers\etc\hosts :

# Copyright (c) 1993-2009 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# This file contains the mappings of IP addresses to host names. Each
# entry should be kept on an individual line. The IP address should
# be placed in the first column followed by the corresponding host name.
# The IP address and the host name should be separated by at least one
# space.
#
# Additionally, comments (such as these) may be inserted on individual
# lines or following the machine name denoted by a '#' symbol.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

# localhost name resolution is handled within DNS itself.
#	127.0.0.1       localhost
#	::1             localhost
windows hosts
Windows 10 hosts file

To change the hosts file on Windows:

1. Press the Windows key

2. Search for the Notepad application and click the Run as administrator link. Editing the hosts file requires administrator privileges.

3. In Notepad >> File >>Open . Navigate to the c:\Windows\System32\drivers\etc\ path and select the hosts file. It might be necessary to view “All Files”.

4. The hosts file is now opened. Add a new line containing the new server IP followed by a space and followed by the domain name of your site.

NEW_SERVER_IP domain_name.com

Example:

11.22.34.55 plothost.com

Do not forget to remove this line after you update the nameservers!


On Linux and Mac systems the file location is /etc/hosts :

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 localhost.localdomain localhost 

To change the /etc/hosts file on Linux/Mac:

1. Connect to your server / open a command line window on the local computer

2. Edit the /etc/hosts file with your preferred editor. Example:

nano /etc/hosts

Leave a Reply