Modifying the host file

What is a host file?

A hosts file is an address book, situated on your local computer that maps a host name to an IP address (network name resolution). Generally, a domain name (host name) is translated to an IP address via the DNS resolution process. However, the host entries that are present in the host file will bypass this DNS resolution.

When will this be useful for you?

  • If you’ve just modified the Name Servers of your domain name, and are viewing the cached results due to DNS propagation.
  • If you’re in the process of migrating to a new hosting server, and want view your website on the new server while it’s still under development. This way you can preview the site, whereas your visitors will continue to view the live website on the old server. Thus, the traffic to your site remains unaffected.

 

How do I do it?

Here’s how 🙂

For Windows:

Go to C:\Windows\System32\drivers\etc and locate the hosts file

1

  1. Open it in any text editor like Notepad, Notepad++, etc

Add your host entries as shown in the snapshot below and save the file

2

That’s it. Flush your DNS cache and browser cache and you should be able to see your website from the server IP you specified in the host file.

For Linux:

  1. Locate the hosts file at /etc/hosts
  2. Run the below command to edit file: vim /etc/hosts
  3. Add your host entries as shown in the snapshot below and save the file.

3

That’s it. Flush your DNS cache + browser cache and you should be able to see your website from the server IP you specified in the host file.

0 Likes
0 Dislikes
1219 Views