How to Edit File Host – A Complete Guide

Host files predate the Domain Name System and can still be found in popular operating systems such as Windows and macOS. They are an effective way to address the same issues as a DNS. But how can you edit a hosts file and locate it?

 

For answers to these questions, keep reading. In this blog, you will find a comprehensive guide on how to edit a hosts file. You will learn what a hosts file is, what it does, and whether you should edit it or not.

What is a Hosts File?

The hosts file works similarly to a DNS. It is a directory that stores the IP addresses of various websites. When you visit a website, your computer will first check the IP address in the hosts file and match it with the relevant hostname.

 

But if the IP address is not found in the hosts file, the computer will then turn to the DNS to look up the website's IP address based on its hostname. The hosts file is present in most operating systems.

Should You Edit a Hosts File?

Editing a hosts file is generally considered safe, as it's a simple text file that can be opened and modified using any basic text editor.

 

The most common reason for editing a hosts file is to change a website's domain name. When moving your website from one hosting provider to another, your site may be temporarily unavailable while the domain name propagates, which can take up to 48 hours.

 

However, by modifying the hosts file on your computer, you can access your website immediately using the new domain name

How to Edit a Hosts File on Windows?

You can edit the hosts file using the two methods below.

1. Through a Text Editor

You can use any text editor but we are using Notepad which is the default text editor on Windows.

 

  1. Search for Notepad in the Search menu and open it by pressing Run as administrator. This option will be visible if you right-click on the icon.

  1. Click on File and then Open.

  1. Use the C:\Windows\System32\Drivers\etc to locate the hosts file. Once you find it, tap on it to open it.

  1. Make the changes as per your needs.
  2. Hit Save or press Ctrl+S. Do not save it as a text file otherwise, the changes won’t be applied.

2. Through Hosts File Editor

Another effective way to make the changes on the hosts file is through the online hosts editor. You will need to download it for it set up. Once it has been installed on your system, you can launch it to make the changes as needed. Add as many IP addresses and domains as you like through the editor. 

How to Edit a Hosts File on macOS?

Here are the steps to edit a hosts file if you have the latest version of the operating system. In this case, it is the Leopard.

 

  1. Open the Terminal.
  2. Locate and open Nanoeditor by running it as administrator. You can do so by entering sudo nano /private/etc/hosts.
  3. Type in your password.
  4. Make the changes and hit save.

How to Edit a Hosts File on Ubuntu?

To edit a hosts file on Linux, you will need an editor. You can choose anyone you like. A couple of them are the gedit editor or the Vim editor. Here, we are using the gedit editor.

 

  1. Open the Terminal.
  2. Type the command, sudo su.
  3. This will ask you for your admin password. Type that in.
  4. Type, sudo gedit /etc/hosts.
  5. This will open up the host file and you can make the desired changes. Hit save once you are done.

Conclusion

All things considered, you can access and modify the hosts file on any platform using the methods outlined in the blog. Hopefully, these methods will grant you access to your hosts file within minutes. While there are several ways to do it on Windows, there are only a few methods for other operating systems. Nevertheless, they are all effective and can assist you in completing your task quickly.

FAQs

Is There a Need to Restart the System After Editing the Hosts File?

No, the changes are made automatically once you hit the save button. There is no need to restart the system.

Is There Any Harm in Editing a Hosts File Manually?

No, there is no such risk in editing a host file without a hosting provider. However, we do suggest not using it to override websites that may invade your personal information.

.com Domain
$5.96/yr
Free 3 months Starter Hosting with every purchase of .COM domain Search Now