How to Edit Windows hosts File and Emulate DNS Change

There is a file on your operating system which can be used to set domain name on the IP address until the domain is registered worldwide. Usually, it takes some time before the domain is registered after the order is submitted or it can take even more time (from 24 to 48 hours) for a domain to start working when you change your hosting provider and point a domain to a different server. Usually, your website does not have its own IP address and here comes the hosts file to help us. If the same IP address is used by several websites, you cannot access your website using IP address directly in the browser. This tutorial explains how to edit Windows hosts file.

What you’ll need

Before you begin this guide you’ll need the following:

  • Administrator rights on a Windows device.
  • Your domain name set on the account and IP address which is set on your account by hosting provider (You can ask hosting provider to provide the IP address your website is using).

Step 1 — Running Notepad as Administrator

You need to run a text editor (Notepad is recommended) as administrator on your computer. Press on the Start button on your Windows, enter Notepad with your keyboard-> Right-click on it and select Run as administrator. If you are prompted for an administrator password – enter it.

Running Notepad as administartor

Step 2 — Opening hosts File

Once you’ve done so, open up the following file using the File -> Open feature:
c:\windows\system32\drivers\etc\hosts (Keep in mind, that All Files should be selected on your notepad dropdown area).

Opening hosts file

Step 3 — Editing hosts File With a Domain and IP Address

Now you should edit this file with the shared IP address on which your account is built and your domain name.

Editing hosts file

On this example, we have entered IP address ( and domain name (www.yourdomain.com). Please keep in mind there shouldn’t be # sign at the beginning of the line otherwise it will not work.

Step 4 — Saving hosts File

Do not forget to save the changes which you have just made. Press the File button on the top left corner and select Save.

Saving hosts file

Step 5 — Entering The Website

Now you should be able to enter your website even without a domain name registered. Simply open the browser and enter the domain name you created in the hosts file. The files located on hosting server should be opened using it.


Please keep in mind this change works on the computer on which hosts file is edited only. You cannot send a link to your friend to check the website until the domain is registered. You should also not forget to remove this line or comment it (using # at the beginning of the line) when the domain is already registered and working.

About the author

Elvinas S.

Elvinas is a senior server administrator at Hostinger. He monitors the infrastructure’s well-being and keeps the uptime at a maximum. Besides server management, web development has always been one of his biggest passions.

Add Comment

Click here to post a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Get Exclusive Content

Join thousands of webmasters who get our free newsletter with tips on how to drive more traffic and revenue to their websites!

Please wait...

Thank you for sign up!