This article will guide you how to add an entry in your machine’s host file to lookup up the A record for a domain directly without DNS name resolution, this is commonly used for testing website before changing the name server as it will override the DNS settings on that  particular machine where you edit the host file. This is a good way to test a site before you have transferred the domain from your old server to new server.

Windows

You need to open and edit the host file using notepad with administrator privilege.

Step1: Navigate to notepad
step2: Right click notepad and select ” Run as administrator”
Step3: Open c:\Windows\System32\Drivers\etc\hosts
step4: Add the following entry.

In the above example, replace the domain name and IP address with your actual domain name and IP address.

Finally your host-file should look like.

Step5: Save the file and access the website using your favorite web browser.

Linux

step1: Open the linux terminal
step2: Open the host file using your favorite editor (here we use “nano editor”).

step3: Add the following lines into your host file.

In the above example, replace the domain name and IP address with yours.

step4: Press control+X , then answer “y” to save the changes.

That’s it!
Go and access your website using any web-browser!

Mac

Step1: Open Mac’s terminal
Step2: Open the host file by entering the following command on your terminal.

Step3: Add the following entries to the bottom of your host file.

In the above example, replace the domain name and IP address with yours.

Step4: Save the changes by pressing control+o, then return to accept the filename.
Step5: Exit the editor by pressing control+x. You are now at terminal screen.
Step6: Flush your Mac’s DNS cache by entering the following command.

Done!
Access the website in your browser and make sure everything is fine.

Note:- Please remove the entries when testing is complete.