Posted on

Trick your Computer Into Finding Web Sites on Other Servers

Published by

Quite often I’ve dealt with moving sites from one hosting situation to another. One issue that comes up is checking to make sure the site works on the new server, but you can’t check it because the domain is still pointing to the old server. Most clients are not okay with just waiting until the DNS switches over to the new server before finding out if their site is broken or not, so what to do? It turns out you can trick your computer into thinking the site really does live on the new server, so you can check it and verify everything is working correctly. Here’s how.

 

Whether you are on Windows, Linux or OS X, you can tell your computer to look for web sites at alternate IP addresses regardless of what DNS servers tell it. There is a hosts file that you can modify to do just that.

 

On Linux and OS X, this file is /etc/hosts, while on Windows it is the C:\WINDOWS\system32\drivers\etc\hosts file. The format is the same on both platforms, so you can use this trick no matter what OS you use. Here is the default one from OS X:

  ##
  # Host Database
  #
  # localhost is used to configure the loopback interface
  # when the system is booting.  Do not change this entry.
  ##
  127.0.0.1       localhost
  255.255.255.255 broadcasthost
  ::1             localhost

The setup is pretty simple. Enter the IP that you want your computer to point to, with the domain name you want it to use. So if you are in the process of moving www.clientwebsite.com from Dreamhost to Bluehost, then you’d find out the IP of the new server at Bluehost and enter at the end of the file like so:

 

  123.123.123.123 www.clientwebsite.com

Now clear out the DNS cache on your computer to make sure you’re not viewing the site from your DNS cache. On windows, open up the command line and type ipconfig /flushdns. In OS X, open up Terminal and type lookupd -flushcache. I also recommend clearing your browser cache.

 

Open up your browser and go to the web site you just entered in the hosts file. It should now point to the new server. If not, make sure you remembered to flush your DNS cache.

 

Now you can save yourself some trouble with moving sites and make sure they work before you switch them over. Your clients will be happy, and more importantly you’ll have peace of mind that you won’t be getting calls from panicking clients that their site is broken.

Leave a Reply

Your email address will not be published. Required fields are marked *