How to edit hosts file?

Why do we need to edit the hosts file for a website/mail service down issue?
After registering/changing hosting server for a domain or renewing an expired domain, its DNS information is not updated to all the DNS servers located in different isp around the world. The DNS propagation takes 24 to 48 hours. Before this DNS propagation, we can temporary visit our website by changing the hosts file of our computer.

Hosts file location:

C:\Windows\System32\Drivers\etc\hosts

After opening the hosts file, at the end of the host file, add the host records entry for your website. The hosts record entry will be the  server IP address with your website name. You can know your server ip address from the mail “cPanel account information” that we have sent when you have activated cPanel account.

Host record entry:
198.12.116.146 www.example.com

You will replace the ip address 198.12.116.146 to the server ip address and website example.com to your website name.

 

Here is the instruction for all the operating system:

Windows 8 and Windows 10

  1.  Search Notepad and Right click Notepad and select Run as administrator
  2.  Click Continue on the "Windows needs your permission" UAC window.
  3.  When Notepad opens Click File -> Open
  4.  In the filename field type C:\Windows\System32\Drivers\etc\hosts
  5.  Click Open
  6. Add the hosts records entry and save the file.

 

Windows Vista and Windows 7

Vista and Windows 7 use User Account Control (UAC) so Notepad must be run as Administrator.

1. Click Start -> All Programs -> Accessories

2. Right click Notepad and select Run as administrator

3. Click Continue on the "Windows needs your permission" UAC window.

4. When Notepad opens Click File -> Open

5. In the filename field type C:\Windows\System32\Drivers\etc\hosts

6. Click Open

7. Add the hosts records entry and save the file.

 

Windows NT/2000/XP

1. Click Start -> All Programs -> Accessories -> Notepad

2. Click File -> Open

3. In the filename field type C:\Windows\System32\Drivers\etc\hosts

4. Click Open

 

Another good resource for editing your hosts file, with pictures, is available here:

http://www.howtogeek.com/howto/27350/beginner-geek-how-to-edit-your-hosts-file/

The process of editing your hosts file is as simple as adding a few lines to a file through a text editor. What this will do is tell your browser what IP address you want to load a domain from instead of looking it up from a DNS server. Here are a few youtube videos that will walk you through setting up your hosts file:

For Windows 8:
https://www.youtube.com/watch?v=6HtODhWg_YA

For Windows 7:
http://youtu.be/psQW6GqM444?t=4s

For Mac OSX:
https://www.youtube.com/watch?v=GmEwA0XMCm8


Using this hosts file method for testing, it may be necessary to clear the cache in your browser before proceeding. Please read the tutorial to clear your local DNS Cache:

https://dhakawebhost.com/clients/knowledgebase/?action=displayarticle&id=112

Once the hosts file is setup, you can go to the site as you normally would and it will show the site as is on the new server. Please remove the hosts record entries when your DNS will be completely propagated within 24 to 48 hours.

Was this answer helpful?

 Print this Article

Also Read

How to Log into cPanel?

There are different options to log into cPanel account. Please Follow the basic steps to access...

CPU Resource Limit

CPU Resource LimitShared Hosting:Dhaka Web host allow 20% CPU resource usage on our shared...

How to View Website Statistics in cPanel Using AWStats?

Step 1: Log into your cpanel by providin your username and password. Step 2: Scroll down to...

Log into cPanel from client panel

Step 1: Log into your client panel.              ** visit: https://www.dhakawebhost.com...

How to Download a Home Directory Backup?

Step 1: Log into your cpanel by providin your username and password. Step 2: Scroll down to...