Guides

Access your site before DNS propagation

How to edit the hosts file to test an offline site

After a hosting plan has been activated, the website files can be transferred using an ftp (file transfer protocol client), using the IP address and credentials given in the service activation confirmation email.

At this stage, however, it is not possible to access the site (in the new hosting) by indicating the assigned IP address or the domain name in the browser. Therefore, in order to carry out a complete test of the site before the registration or transfer of the domain is effective, which means before all the DNS (Domain Name System) servers are updated with the new address, it is necessary to use other tools. Here are some suggestions.

In addition, a video-guida is available on our YouTube channel:
How to edit the hosts file to test a website offline

Hosts file configuration

Each PC contains the hosts file (NB: without an extension) which allows you to force the resolution of a domain name to a specific IP address, by-passando the DNS servers.

This file is located in different locations depending on the operating system used; in particular:

  • MS Windowsoperating system: the hosts file is located in C:\windows\system32\drivers\etc\.
  • UNIX-like operating system: (Linux, UNIX, etc) the hosts hosts file is usually located in /etc/.
  • macOS operating system: the hosts file is usually located at private/etc/

Modifying the hosts file

Insert a line of text in the hosts file with the IP address of the hosting plan that hosts the website together with the domain name, as in this example and the next image:

194.242.XXX.XXX www.nomedominio.estensione

Obviously, the IP address in the example is fictitious, and must be replaced with the IP address of the new hosting.

Save and close the file. Open the browser and type in the name of the website, which will now be visible even if the domain registration/transfer has not been completed.

IMPORTANT NOTES

  • If the hosts file is read-only you will not be able to edit it. Therefore, uncheck the 'read-only' attribute in the file properties.
  • At least one space must be left between the IP address and the domain.
  • The hosts file must be saved WITHOUT EXTENSION, otherwise the changes will not be applied.
  • Typing the IP address in the browser will not allow you to view the website.
  • Delete the line from the hosts file only when the propagation (to the DNS servers of the new IP address for the domain in question) is complete.

Browser plugins or extensions

Some browsers have extensions or plugins that allow browsing a site whose address is not yet propagated on the DNS servers.
For example, the well-known browser Chrome (and also Chromium) has the Virtual Hosts extension that can be installed from the following link: Virtual Hosts for Chrome. For details on how to use it, see the documentation at the same link.