How to view your website on browser before DNS propagation

If you bought new domain, hosting and you want to view your designed content immediately on web browser before DNS propagation ? If so, its possible by mapping your server IP to domain name into hosts file. If you have hosted your domain using web hosting control panel then no issues, you will have option to view without adding the entry into host file.

1) What is hosts file ?

The hosts file is a computer file used by an operating system to map hostnames to IP addresses.

2) DNS not yet propagated ?

See the below screen shots DNS not yet propagated.
how-to-view-your-website-on-browser-before-dns-propagation-1
That’s why the below website not loading on browser, when i access.
how-to-view-your-website-on-browser-before-dns-propagation-2

A) How to do it in LINUX

Follow the below steps to done on LINUX.

a1) How to map your IP & domain in Linux

Open the /etc/hosts file with your favourite text editor and add the below colored lines then save & exit. You need to add your server IP and your domain name instead of ours.

$ sudo nano /etc/hosts

127.0.0.1       localhost
127.0.1.1       magesh-desktop

# Site mapping before DNS propagation
83.170.117.116       balajeeplacment.com
83.170.117.116       www.balajeeplacment.com

a2) Flush DNS cache ?

After making changes in hosts file, you need to clear your DNS cache. Use the below command to do it. For other DNS cache flush.

$ sudo /etc/init.d/dns-clean start
 * Restoring resolver state...          [ OK ] 

a3) Site loading on browser

Now, its loading on browser without any issues.
how-to-view-your-website-on-browser-before-dns-propagation-3

B) How to do it in WINDOWS

Follow the below steps to done on WINDOWS.

b1) How to map your IP & domain in WINDOWS ?

Navigate to below directory and open the hosts file on text editor and add below colored lines then save & exit. You need to add your server IP and your domain name instead of ours.
C:\windows\system32\drivers\etc\hosts

# Copyright (c) 1993-2006 Microsoft Corp.
#
# This is a sample HOSTS file used by Microsoft TCP/IP for Windows.
#
# For example:
#
#      102.54.94.97     rhino.acme.com          # source server
#       38.25.63.10     x.acme.com              # x client host

127.0.0.1       localhost
::1             localhost

83.170.117.116       balajeeplacment.com
83.170.117.116       www.balajeeplacment.com

b2) Flush DNS cache ?

After makking changes in hosts file, you need to clear your DNS cache. Use the below command to do it.

C:\Users\Administrator>ipconfig /flushdns

Windows IP Configuration

Successfully flushed the DNS Resolver Cache.

b3) Site loading on browser

Now, its loading on browser without any issues.
how-to-view-your-website-on-browser-before-dns-propagation-3
We are preparing all articles in-depth to understand by all level/stage Linux administrators. If the article is useful for you, then please spend less than a minute to share your valuable comments in our commenting section.

Please stay tune with us…Good Luck.

Magesh Maruthamuthu

Love to play with all Linux distribution

You may also like...