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.

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

āĻāĻ‡ āĻ•āĻ¨āĻŸā§‡āĻ¨ā§āĻŸ āĻŦāĻžāĻ‚āĻ˛āĻžāĻ¯āĻŧ āĻĒāĻĄāĻŧā§āĻ¨: āĻ‰āĻ‡āĻ¨ā§āĻĄā§‹āĻœā§‡ āĻšā§‹āĻ¸ā§āĻŸ āĻĢāĻžāĻ‡āĻ˛ āĻŦā§āĻ¯āĻŦāĻšāĻžāĻ° āĻ•āĻ°ā§‡ āĻ•āĻŋāĻ­āĻžāĻŦā§‡ āĻāĻ•āĻŸāĻŋ āĻĄā§‹āĻŽā§‡āĻ‡āĻ¨āĻ•ā§‡ āĻ•ā§‹āĻ¨ā§‹ āĻ¸āĻžāĻ°ā§āĻ­āĻžāĻ°ā§‡ āĻĒā§Ÿā§‡āĻ¨ā§āĻŸ āĻ•āĻ°āĻŦā§‡āĻ¨?