Temporary access with an undelegated domain
Updated last month
On our computer, we can edit the hosts file to force access to a site as if it were hosted at an IP address different from the one used by its DNS.
This is particularly useful when migrating our site to another server, so we can verify access before pointing the domain.
This file indicates which IP address to look up for a particular domain, bypassing the traditional method of finding its location through DNS servers.
If you don't remember the IP address or your username, please contact us so we can send you the details again.
What is the hosts file, and where is it located?
The hosts file is an ordinary text file. However, its simple nature is somewhat "hidden" because it does not have the typical .txt extension.
The location of '*hosts*' in Windows is as follows (note: if we use Linux or MacOS, we will find the relevant instructions below):
C:Windows/System32/drivers/etc
And no, it is not a driver, even though it is located in the "drivers" folder. It seems that on the day they were trying to agree on where to place the hosts file within Windows, Mr. Bill had gotten out of bed on the wrong side.
Although, as we have pointed out, it is a simple text file, because it is located inside a system folder, we can only edit it with administrator privileges.
Doing this is easy: we simply open our "notepad" app, but right-clicking it so we can find the necessary option:
A prompt will appear asking us to allow Notepad to edit protected system files. Something like this:
Of course, we must click the "Yes" button.
Once this is done, the text editor will appear on screen just as we know it (except that it will allow us to edit and save the hosts file). In Notepad, we will go to Open and look for the hosts file in the previously indicated path (C:WindowsSystem32driversetc).
Attention: when we reach the 'etc' folder, we will not see anything. The reason is that none of the files in that folder have the .txt extension.
To view the hosts file, we will click where indicated in the screenshot below and select "All files (.)":
Voilà!
The content of the hosts file is quite brief. It will contain little more than an informational text in English explaining its purpose. We must type the relevant line below this information. For this example, we used one of Duplika's DNS servers and the typical fictitious name www.misitio.com
Clearly, we must enter the real DNS provided by our hosting service and write the correct path for our actual site (it might not use WWW).
Once finished, we will save the changes and close Notepad.
Done. Our operating system will now not look up our website's IP address via DNS, as usual. Instead, it will already know the IP address of the server where our site is hosted, whether DNS propagation has finished or not.
How do I edit the hosts file in Linux?
In Linux, we can use any text editor we prefer:
nano /etc/hostsOnce the file is open, we will add our site's IP address and domain just as shown in the screenshot above for Windows.
How do I edit the hosts file on Mac?
To edit the hosts file on MacOS, we will open Launchpad and look for the "Terminal" app. In the Terminal window, we will enter the following code:
sudo nano /private/etc/hostsWe will enter our Administrator password, and the hosts file will immediately open on Mac.
Thanks to this edit, our operating system, as explained, will not rely on Internet DNS to find our site's server. Instead, it will know it without having to wait for DNS propagation to finish. As a result, we will see our site immediately and/or be able to work on it to get it ready.
We hope this article has been very helpful. We invite you to leave suggestions, questions, and experiences in the comments section. Best of luck, and thanks for reading.