Temporary access with an undelegated domain
Updated 3 months ago
On our computer, we can edit the hosts file to force access to a website as if it were hosted at an IP address different from the one its DNS servers use.
This is particularly useful when migrating our site to another server, so we can check access before pointing the domain to it.
This file specifies which IP address to look up for a given domain, bypassing the traditional method of finding its location through DNS servers.
If you don't remember the IP address or your username, please write to us and we'll send you the details again.
What is the hosts file, and where is it?
The hosts file is an ordinary text file. However, its simple nature is somewhat "hidden" because it doesn't have the usual .txt extension.
The location of '*hosts*' in Windows is as follows (note: if we have Linux or MacOS, we'll see the relevant instructions below):
C:Windows/System32/drivers/etc
And no, it's not a driver, even though it's in the "drivers" folder. It seems that on the day they were supposed to agree on where to put the hosts file in Windows, Mr. Bill had gotten out of bed on the wrong side.
Although, as we've pointed out, this is a simple text file, because it's in a system folder, we can only edit it with administrator privileges.
This is easy: simply launch our "Notepad" app, but right-click it to find the following option:
A dialog will appear asking us to allow Notepad to edit protected system files. It will look something like this:
Of course, we must click the "Yes" button.
Once we've done this, the text editor we're familiar with will appear on screen (except that it will let us edit and save the hosts file). In Notepad, we'll go to Open and find the hosts file at the path indicated earlier (C:WindowsSystem32driversetc).
Note: when we reach the 'etc' folder, we won't see anything. This is because none of the files in that folder have a .txt extension.
To see the hosts file, we'll click where indicated in the screenshot below and select "All files (.)":
Voila!
The contents of the hosts file are very brief. It will contain little more than some explanatory text in English describing its purpose. We need to type the line we need below this information. For this example, we've used one of Duplika's DNS servers and the typical fictitious name www.misitio.com.
Clearly, we must enter the actual DNS servers provided by our hosting service and type the correct address for our actual site (it may not include WWW).
When we're done, we'll save the changes and close Notepad.
Done. Our operating system will now stop looking 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 or not DNS propagation has finished.
How do I edit the hosts file in Linux?
In Linux, we can use any text editor we like:
nano /etc/hostsOnce the file is open, we'll 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 a Mac?
To edit the hosts file on MacOS, we'll open Launchpad and search for the "Terminal" app. In the Terminal window, we'll type the following code:
sudo nano /private/etc/hostsWe'll enter our administrator password, and the hosts file will open on the Mac.
Thanks to this edit, as we explained, our operating system won't rely on Internet DNS to find our site's server. Instead, it will already know where to find it without waiting for DNS propagation to finish. As a result, we'll see our site right away and/or be able to work on it and get it ready.
We hope this article has been very helpful. We invite you to share your suggestions, questions, and experiences in the comments section. Best of luck, and thanks for reading.