Theme Surgeons

Hosts file: How to connect a new site using a hosts file?

Hosts file allows you to access at a web site before that web site is publicly available. It’s especially useful when migrating from one web hosting company to another.

Warning: always make a copy of your of any system file so you can restore it if something should go wrong. Make sure you follow the directions below. This solution is really great for connecting to a new site while waiting for DNS records to propagate.

The hosts file is used to map host names (in other words domains) to IP addresses. With the hosts file you can change the IP address that you resolve a given domain name to. This change only affects your own computer without affecting how the domain is resolved worldwide.

Hosts file highlighting a host name to resolve to a specific IP address.

This is particularly useful when you wish to see how a website will look like when hosted on a different server without making any DNS changes to your domain.

The location of the hosts file, depending on the operating system that you are using, is:

Let’s say that you wish to resolve yourdomain.com to the IP address 1.2.3.4. In this case you would need to open up the file with a text editor and append the following line:

11.2.3.4 yourdomain.com www.yourdomain.com

(Note: Make sure that you don’t have any # signs in front of the IP address as they will deactivate this entry)

This will “tell” your computer to resolve yourdomain.com to 1.2.3.4. Once you do that you may need to clear your web browser’s cache, afterwards, if you try to reach your domain http://yourdomain.com in a browser it should take you to the site hosted on the server with IP 1.2.3.4.

More detailed instructions on how to locate and edit the hosts file on different operating systems are available below:

Windows 8 and 10

Linux hosts file

Mac OS X 10.6 through 10.12

You should be logged in with a user with administrator privileges on your MAC.

Based on a post originally created by Site Ground

Exit mobile version