If you have recently bought a new domain name and web hosting account OR you have just switched your hosting provider, then you will have to wait for some hours before you can actually view your website over the internet! The reason behind this wait is DNS Propagation.
What is DNS Propagation?
DNS stands for Domain Name System and whenever you try to visit a website (say dailytechtuts.com), your request for dailytechtuts.com goes to your Internet Service Provider’s local DNS server. The server will now check if it knows the IP address of dailytechtuts.com. If it knows this information, then you will be able to access this blog instantly. But in case it doesn’t have the information about IP address in its cache, then your query is sent to the root name server.
Whenever you register or transfer a domain, it is added instantly to the root name server and when the domain expires, it is removed from it. The root DNS server gives information about Primary and Secondary DNS server (combinedly known as Authoritative Name servers) to your ISP’s server.
The local DNS server will now query the authoritative name servers so that it can know the IP address of dailytechtuts.com.
Your ISP’s server will now make a cache of this information. Caching is necessary as it speeds up further queries for same domain name and it also reduces the load on root server. This whole caching process is known as DNS propagation and it may take up to 72 hours to complete worldwide for each and every ISP like AirTel, Vodafone, AT&T, Verizon, Comcast etc.
Note: The local server of each ISP don’t store the IP address information for each website forever. It keeps the information in its cache for certain amount of time and after that it gets deleted completely. After deletion when you try to visit a website, the process described above starts all over again.
How to view your website much before the actual Propagation?
In order to view your website before propagation, you will need the IP address of your web server. You need to point your computer directly to this IP address, so that there’s no need to communicate with your ISP’s DNS server or third party servers from Google DNS, OpenDNS etc.
The IP address of your server is generally present in the welcome email that you received just after signing up with your hosting provider OR it is visible in your hosting account’s control panel (cPanel, Plesk etc.):
You can also ping your website using Command Prompt (cmd) to know its IP address:
Another way of knowing the IP address is to make use of your WHOIS record. WHOIS protocol allows you to send queries to a database which stores information about people (name, phone number, address etc.) and their domain name/server (IP address, type of server etc.). Feel free to check out the IP information of DTT right here:
In case you are still unable to determine your site’s IP address, then it’s highly suggested to open a support ticket with your hosting provider and ask them directly.
Once you know your server IP address, we are now required to temporarily alter the Hosts file of your computer’s operating system. The location of hosts file varies from one version/OS to another:
- For Windows 95, 98 OR ME (Millennium Edition), the location of hosts file is c:\windows\hosts.
- If you are using Windows NT or 2000, then the file is located at c:\winnt\system32\drivers\etc\hosts.
- For Windows XP, Vista, 7 and 8 (including 8.1), the location is: c:\windows\system32\drivers\etc\hosts.
- For Mac OS X, its location is /private/etc/hosts.
How to Edit Hosts file?
For Windows 95, 98, ME, NT, 2000 and XP:
1. Depending on the version of the operating system you are using, copy the address of hosts file from above. Now Open Notepad by going to Start >> All Programs >> Accessories >> Notepad OR Start >> Run >> Type Notepad.
2. When the program opens, click on the File menu and select open (CTRL + O) and paste the location of hosts file that you copied earlier in the File name’s field and click on Open button:
When the file opens, you will see localhost IP address written at the bottom of the file:
3. Just after the IP address of localhost, enter the IP address of your server, Press Tab Button once and then enter your domain name/sub-domain each separated by a space:
4. Save the file and exit Notepad. You may also want to clear your browser’s cache and flush DNS.
Note: It’s a good idea to include your domain with and without www.
For Windows Vista, 7 and 8:
1. Click on Start Button >> All Programs >> Accessories and look for Notepad icon. Now Right Click on the icon and Select Run as Administrator:
2. Click Open (CTRL + O) in Notepad and paste the Hosts file address in the File Name’s field >> Press Enter and select All Files from the drop down menu:
3. Enter your web server IP address and domain/sub-domain at the bottom of the file, just like we did earlier. Save the file and exit Notepad.
6. Restart your browser after clearing its cache and flushing DNS on your computer. Type your domain name and your website will load on your computer directly from its web server.
Note: You can see the above steps in action for Windows 7 OS in following video:
For Mac OS X
If you are using Macintosh and want to preview your website directly from your server without using DNS, then following are the steps to do so:
1. Open Terminal of your operating system by going to Applications >> Utilities >> Terminal. Once the program is open, type following command to directly open the hosts file:
sudo nano /private/etc/hosts
2. Editing of hosts file requires administrator or root privileges and because of this you will get a password prompt. Type the password of your administrator account and the hosts file of your system will be displayed on your screen.
Use arrow keys to go to the bottom of the file and at the bottom enter the IP address of your server and then enter your domain name/sub-domain each separated by a space. Make sure you enter your domain with and without www:
<Server IP Address> <Domain/hostname>
3. Press Control-O (not zero) to save the file and press enter when the file name prompt appears with hosts written. Press Control-X to exit the editor.
- As soon as the DNS has been propagated for your location/ISP, you may want to undo all the changes that you have done in your hosts file. You can get an idea about the completion of propagation by pinging your website using over 30 monitoring stations worldwide. If you start seeing the IP address of your new web server for a particular monitoring station, then chances are very high that the domain has been propagated in that country.
- On Macintosh, if you are unable to edit hosts file as an administrator, then you may have to use this command: sudo chflags nouchg /private/etc/host.
- For resetting the DNS cache on Macintosh OS, you are required to use this: sudo killall -HUP mDNSResponder OR this: sudo dscacheutil -flushcache terminal command.
- Some security suites may not allow you to alter your OS’s hosts file. You may want to temporarily disable them before you start making the changes.