The hosts file is used by your local computer’s operating system to resolve hosts names to IP addresses. It is a plain text file and is usually named hosts.
This file is really useful when you have just moved a website to a new hosts as you may want to know how your site works on the new server at the first time so you can troubleshoot any problem or error on your website before going live and update the DNS name servers or a records for your domain.
How to use the hosts file is pretty simple, let’s say we have the DNS named clickittech.com and you want it to point to the IP address 10.10.10.1, you have to look for the hosts file on you operating system (see instructions below) and add a line with the next format:
And then just save the configuration on the file, once this is done, now we have to open a browser and type the domain in it, and you will be pointed to the IP specified on the hosts file, to see how the site is behaving in this new server, if you want to stop resolving to the new IP you only have to erase or comment the line added.
- Go to “My Computer” or “Computer” and go to your local disk of Windows.
- Go to Windows and Scroll down until you locate your System32 Folder.
- Open the Drivers folder and go to the “etc” folder.
- There you will see your “hosts” file.
- Double Click on it and select Notepad to run it.
- Go to the ips which are not 127.0.0.1. There you can add any ip which you want to emulate the DNS change.
- Add a new line in the hosts file with the format of“ip-address domain.com www.domain.com”
- Save your hosts file in Desktop
- Remove the “.txt” extension from the hosts Desktop file
- Go to your etc folder and replace the hosts file
- (if you don’t remember how to go “etc” folder Follow steps 1-4)
Linux and MAC OS:
- Sudo nano /etc/hosts
- Type your password
- You will see your host file
- Use arrow keys or mouse to move thru text
- Add a new line in the hosts file with the format of “ip-address domain.com www.domain.com”
- Ctrl+X to exit from nano
- Press Y = Yes
Or You can use this MAC tool: Gas Mask It allows you to easily edit the hosts file.
In order for the hosts file settings to take effect, please restart the browser. You can now access your website hosted using the domain name.
As we can see in this blog, using the hosts file is a secure and easy way to test our migrations and troubleshoot any possible problem, here at ClickIT we implement this practices to migrate our sites in the cloud, combining high security, scalability, and redundancy. ClickiT aims to provide secure and high-quality service for the satisfaction and comfort of our clients. Our Agile Team also includes leading IT experts in application migration in the cloud, web security, web development, IT automation, clustering, scalability and near-shore support. Contact Us Now!
Do you want to migrate to the cloud?
We can help you to choose the right hosting.