Tag: hosts

  • Preview Website Before Name Server Change

    When migrating web site to new server, it is good to test the site from new server before you actually change the name servers. Doing this will avoid unexpected errors after you make site live from new server.

    To do this, you need to edit file with name hosts on your computer. Add following content to it.

    NEW_IP_ADDRESS www.yourdomain.com yourdomain.com
    

    Example

    127.0.0.1 www.serverok.in serverok.in
    

    At this point, if you take command promt on you computer and type folloing command, you will see the new server IP.

    ping www.yourdomain.com
    

    Now you may need to restart the browser for browser DNS cache to clear. Now you will be able to see the site from new server.

    Location of hosts file

    Location of hosts file depends on Operating System you use.

    Windows

    You need to edit the file c:\Windows\System32\Drivers\etc\hosts

    To open, you need Administrator privilage, so run notepad as user “Administrator”, then open above file to edit it.

    Linux and Mac

    The file is located in /etc/hosts, to edit use

    sudo vi /etc/hosts