How to view sites before changing DNS hosts file

When you are migrating your site between servers, you can edit your computer's "hosts" file so you can view your site when the DNS may not be working correctly.

This is an example of a typical hosts file:

127.0.0.1localhost

The first item is the IP address that you would like the domain name to resolve to. The second is the domain. For example, if I wanted mydomain.com to point to IP address 127.127.127.127 I could type:

127.127.127.127mydomain.com www.mydomain.com

This will redirect mydomain.com and www.mydomain.com to 127.127.127.127. You can use this tool to test whether your sites are working after the migration, while still leaving your original site online. Simply, point the desired IP to the domain name and your computer will connect to the new IP whenever you type in the domain name.

The hosts file is located is different places, depending on the operating system. However, it is always called "hosts".

Mac OS X

On Mac OS X, the hosts file is located here:

/private/etc/hosts

Administrative privileges are required to edit this file.

Windows

On Windows Vista and 7 the hosts file is located:

%SystemRoot%\system32\drivers\etc\

(Typically: C:\Windows\System32\drivers\etc)

Administrative privileges are required to edit this file.

Linux

On Linux, the hosts file can be found:

/etc/hosts

You may need administrative privileges.

Please remember that after the migration is complete, to revert the hosts file to it"s original state.

If you require further assistance please contact our support team.

Is article helpful?