Editing a hosts file

Editing a hosts file

The hosts file is used by the operating system to link domains to IP addresses. This file is very convenient to adjust when a site is moved to a new server but your domain is still directed to the old server. In cases like that, you can edit Hosts file on your computer and see how the website is working on a new server. All other visitors will be redirected to the old server but you will be able to see the website from the new server on your computer.

Typically, this file records in the following format:


IP_ADDRESS: The server from which the site will be loaded
(SUB) DOMAIN: subdomain or domain to be temporarily (locally) directed to the specified IP address

Suppose the site, which runs on server, is required to be loaded from the server for testing purposes The following lines should be added to the Hosts file:

File editing

On each OS hosts file is stored and edited in slightly different ways. Major OS:

Windows 7, 8, 10:

Catalog: %systemic%\32\system\drivers (most often C:\windows\system32\drivers\etc\)
Title: hosts
Spec. Requirements: Must be edited as administrator.

Apple Mac OS X 10.2 and higher:

Catalog: /etc/ or /private/etc/
Title: hosts
Spec. Requirements: Must be edited as administrator.

Most Linux versions:

Catalog: /etc/
Title: hosts
Spec. Requirements: Must be edited with root privileges

You can find a common list here

Was this article helpful?

Related Articles


Need Support?

Can't find the answer you're looking for?
Contact Support