Published on: 15 Jan, 2019

How to add a fake domain name in windows hosts file?

Tumblr Digg Google Plus

If you ever develop a web application, you may need to alter your local DNS file to host some fake domain name. One of the purpose to do this is for local development. It will be faster and easier access for a developer to debug and develop your web app. In this tutorial, we will learn how to add some fake domain name in a Windows environment. We are going to open a hosts file in your Windows folder and add some DNS entry.

Let's say you have a case where you have a live domain name called bytutorial.com and you want to add a fake domain name called local.bytutorial.com just for local development purposes. What you need to do is go to your Windows folder to find the host file. By default, most of the windows folder is installed under C drive. So if you can navigate to the following folder path.

C:\Windows\System32\drivers\etc

You will see there is a file called hosts. To modify this file, you need a text editor. You can use the default notepad comes from Windows or you can the popular Notepad++ program. Remember you need to open this program in Administrator mode. Otherwise, you will not be able to save the hosts configuration file. If you open the file, you will see the content of the hosts file like below screenshot.

To point the fake DNS domain name, you can just need to enter your local IP address which will be 127.0.0.1 then followed by a space and the domain name. For example below is an entry to add local.bytutorial.com to our DNS list.

127.0.0.1 local.bytutorial.com

Once you have saved the file, you can try to ping the domain name in the command prompt and you will see the IP address of the domain name you just enter will be 127.0.0.1.

Hopefully, this tutorial helps and if you have any question feel free to post your message below.

Comments

There are no comments available.

Write Comment
0 characters entered. Maximum characters allowed are 1000 characters.