HostArmada Web Hosting Knowledge Base

Knowledge is power! Use that power and achieve total and unconditional control over the Web Hosting Services!

How can I edit my local hosts’ file?

Whenever you access a website by entering a domain name in the Web Browser of your local computer or mobile phone the first thing that your device will do is to search for the IP address of the accessed domain name. Typically the DNS service will kick in finding the requested IP address and then it will deliver it to your Web Browser so you can access the desired website. However, before the DNS service kicks in, your operating system has the option to return the IP address of a domain name that is on a special list. This list is called the "hosts" file and it is stored within the system files of your operating system. 

The main and only purpose of the "hosts" file is to map hostnames or domain names to IP addresses before the DNS, thus completely disabling the usage of that system. By modifying the "hosts" file, you will be able to ignore the current globally available DNS settings for your domains and make them resolve elsewhere but only for your local computer. In other words, you will instruct your computer to resolve domain names on specific IP addresses without the need of updating the DNS records for your domains.

This option is particularly useful after migrating your website to HostArmada, and you want to make sure the site is working correctly.  Let's assume you have just moved a website on our servers, but you do not want to point your domain name immediately because you are worried that a specific function on your site does not work correctly on the new environment. By adding a line or two in the "hosts" file of your operating system, you can test all of the website's functionalities immediately, and when you make sure that they all work as expected, you can change the DNS records accordingly.

Windows

Please follow the steps below to open your hosts' file on a Windows machine:

  1. First, open your start menu and within the search field, type "NotePad".
  2. When the result presents itself, please right-click on it and from the dropdown, select "Run as administrator". This action will open "NotePad" with administrative rights. 
  3. From the menu bar at the top of the window, please click on "File" and then from the dropdown, select "Open..."
  4. Afterward, please navigate to the following directory C:\Windows\System32\drivers\etc\ and expand the dropdown menu, located at the bottom right side of the window. From the available options, please select "All files".
  5. After selecting the "All files" option from the dropdown, you will immediately notice the "hosts" file show up in the middle of the window. Please select it by using the left mouse button and then press the "Open" button located on the bottom right side of the window. 
  6. The above action will open the file and on the bottom of the file itself, please insert these lines:
<new server IP> <yourdomain.com>
<new server IP> <www.yourdomain.com>

      7. After you are done, please save the file by pressing the "File" option from the menu on top and then select "Save".

Here is an example of what your entry should look like:

1.2.3.4 hostarmada.com
1.2.3.4 www.hostarmada.com

macOS

Please follow the steps below to open your hosts' file on a macOS machine:

  1. Please open your terminal and write the following command:
sudo vim /private/etc/hosts 

      2. You will be prompted for your sudo password. Please type it in to open the hosts' file.
      3. When the file opens, please press the 'I' key on your keyboard, navigate to the bottom of the file using the arrow keys and insert the lines:

<new server IP> <yourdomain.com>
<new server IP> <www.yourdomain.com>

      4. Save the changes by pressing the ": + w + q" buttons consecutively and hit the "ENTER" button.

Depending on the used text editor these steps can vary, however, the path to the file will remain the same.

Here is an example of what the line may look like after the following the template shown above:

1.2.3.4 hostarmada.com
1.2.3.4 www.hostarmada.com

Linux

Please follow the steps below to open your hosts' file on a Linux machine:

  1. Please start your Terminal. Execute the following command:
sudo vim /etc/hosts 

       2. You will be required to enter your sudo password. When the file opens, please press the 'I' key on your keyboard, navigate to the bottom of the file using the arrow keys and insert the lines:

<new server IP> <yourdomain.com>
<new server IP> <www.yourdomain.com>

      3. Save the changes by pressing the ": + w + q" buttons consecutively and hit the "ENTER" button.

Depending on the used text editor these steps can vary, however, the path to the file will remain the same.

Here is an example of what the line may look like after the following the template shown above:

1.2.3.4 hostarmada.com
1.2.3.4 www.hostarmada.com

Was this article useful and on point?

Find out more about HostArmada entire range of optimized Web Hosting Services and take action today on improving your website Loading Speed, Security, and overall Stability!