Tutorials • Domains
Accessing the site from hosting without changing nameservers through the hosts file
In this tutorial, we will go through the necessary steps to access a website hosted on a server without needing to make a change at the nameserver level, using the operating system's hosts file.
5
Views 2503Updated 1 anPublished on 24/01/2018by Cătălin Adrian
Introduction
- The hosts file of the operating system allows access to websites hosted on a server without the need for a DNS server or changing the nameservers on the domain. It can also be used for development purposes, in case we do not own the domain but have hosting.
Requirements
- In order to use the hosts file of the operating system, we will need the IP address on which the domain we wish to access is hosted and the location of the hosts file.
The hosts file is located in the following locations depending on the operating system used:
c:\Windows\System32\Drivers\etc\hosts - Windows
/private/etc/hosts - Mac OS X/etc/hosts - Linux
Steps
- In this tutorial, we will use the Windows operating system as an example. To edit the file, we will start the text editing application Notepad (with administrative privileges) or any other text editor (we recommend Notepad++) and we will open the hosts file by clicking on File from the top bar, then Open. In this case, we will open the file from the path c:\Windows\System32\Drivers\etc\hosts (The c:\ drive letter may vary depending on the location of the operating system installation). We will also ensure that Notepad has the option All Files (*.*) selected from the right side of the File Name field, in order to view all types of files.
- Once the file is opened, we will add the following lines:
SERVER_IP_ADDRESS exampledomain.xx
SERVER_IP_ADDRESS www.exampledomain.xx - As an example, we will use the domain hostico.net hosted on the server with the IP address 89.44.200.147. In this case, we will add the following lines to the hosts file and save the changes made:
89.44.200.147 hostico.net
89.44.200.147 www.hostico.net
- Your hosting-related domain and IP will be used. The lines above are just examples. The hosting IP is included in the email with the administration details.
- Multiple domains and subdomains can be added to the hosts file that point to different servers (IP addresses), with the same functionality.
- In the next step, we will open a browser and test if the domain is loading from the desired server. It is recommended to clear the browser's cache before attempting.