You are currently viewing How to point a domain to a server using hosts file in Windows?

If you need to quickly point a domain name to a server, but do not want to change the nameserver of the domain, then you can do that with the windows hosts file. The hosts file is a local zone record where you can modify or add a record for domains that will immediately work on your computer.
For example, if your domain is currently pointed to another hosting provider, and you are migrating the website to IT Nut Hosting. You might not want to change the nameserver of the domain yet until you have finished the website migration.

So, if you want to change the DNS record of that domain to point to the new server only for yourself, you can use the hosts file. The rest of the world will still visit your website and be taken to the previous hosting provider. You will need to know the IP address of the server where you want to point the domain. You will receive the IP address for your hosting server once your hosting order is confirmed. To modify the hosts record, follow the instructions:

  • Windows hosts file located at “C:\Windows\System32\drivers\etc” go there and copy the “hosts” file from there to your Desktop.
hosts file
  • Open that file with the “Notepad” text editor from the desktop.
open with notepad
  • You will see some descriptions on that file. If you see the # symbol at the beginning of a line, that is a comment and is not any type of command. Go to the bottom of that file and enter the server IP address on a new line.
  • Press the “Tab” button on your keyboard twice to create some space, then enter the domain name.
  • Press enter to create another new line, enter the same IP address, press the tab twice and this time, enter the domain name with www. at the beginning of it.
edit hosts file
  • Now save the file from “File” > “Save”
  • Now copy this “hosts” file from Desktop and paste it to the “C:\Windows\System32\drivers\etc” folder
  • When prompted to replace the existing “hosts” file, click on the “Replace the file in the destination” button. After that, click on the “Continue” button when prompted for Administrator permission as the ‘hosts’ file is a system file.

Once you have done that, you can now visit that domain, and you will be taken to the IP address that you have specified.

You can easily reverse the changes by opening that hosts file from Desktop, put the “#” symbol at the beginning of those two lines or remove those lines altogether. Then save the file and copy it to the “C:\Windows\System32\drivers\etc” folder as before.

How to Recover WordPress password?

Just like that, you have successfully pointed your domain to a server and once the work is done, you have also reversed the changes.

এই কনটেন্ট বাংলায় পড়ুন: উইন্ডোজে হোস্ট ফাইল ব্যবহার করে কিভাবে একটি ডোমেইনকে কোনো সার্ভারে পয়েন্ট করবেন?