18 March, 2023

What Is the Hosts File? Where Is the IP Address File Stored?

Quick summary: The Hosts file stores the IP addresses of servers and the website domain names pointed to them.

File Host is used for many purposes, including stronger security, website redirection and testing on a web server… It is one of the important files when editing and setting up a system. Everything about File host what the Hosts file is, where it is located and how to open it will be MONA Media shared in detail in today's article.

What is the Hosts file?

File Host is a file that stores the IP addresses of servers and the website domain names pointed to them. You can think of the Hosts file as a small DNS directory on your operating system. From the Hosts file you can tell the IP of the server where a domain is managed.

HOSTS.TXT was originally maintained by hand. Later, DNS automated the publishing process. Today the Hosts file exists in modern operating systems and holds real power on all of them, including Windows, macOS and Linux.

The Hosts file is very easy to use because it needs no declarations. It maps a hostname to an IP easily without querying DNS.

Where is the Hosts file located?

The Hosts file is structured in lines. Each line has 2 fields separated by one or more tabs, and sometimes by spaces.

The usual format is: <IP address> <domain name>.

The IP address can be static or dynamic and matches the corresponding domain name. The default IP in the Hosts file is usually 127.0.0.1 (localhost). When you add the line 127.0.0.1 dev (http://dev), localhost will appear. Windows, macOS and Linux each open the Hosts file through a different path. Specifically:

  • On Windows, open the Hosts file by: C:WindowsSystem32driversetc.
  • On Linux, open the Hosts file by: /etc/hosts.
  • On macOS, open the Hosts file by: /private/etc/hosts.

What the Hosts file is used for

What the Hosts file is used for

File Host It has great power and supports many special functions, so many operating systems use it. Using the Hosts file brings many benefits, such as:

1. The Hosts file protects user privacy

By configuring the Hosts file you can block ads from unwanted sources. In particular, the Hosts file can stop third parties from reaching a website, protecting privacy as well as possible.

2. Smooth website redirection

The Hosts file can be used to redirect a website, sending visitors automatically from one site to another. It's very simple: open the Hosts file and add this line at the end: 46.250.210.219 yourdomain.com

  • 46.250.210.219 is the IP address of the website you want to redirect to.
  • yourdomain.com is replaced with the site name typed into the browser. That name will be pointed to the IP you set above.

Using the Hosts file this way gives an uninterrupted redirect. Users reach the site and are redirected to another website more smoothly.

3. The Hosts file helps block harmful websites

Businesses, families and internet cafes often use the Hosts file to block harmful websites. Any site you don't want others to visit can be blocked with the Hosts file. They don't have to be harmful sites; any web address you don't want users to reach can be blocked.

The Hosts file is mainly used to keep users (or yourself) away from harmful websites in an increasingly toxic internet. This is especially useful for families with young children using internet-connected devices, and for internet cafes and public computers.

To block a website, use this syntax: 127.0.0.1 website address. For example, 127.0.0.1 kenh14.com. Users can't open Kenh14 from a computer whose Hosts file has this entry.

Some companies and businesses also use the Hosts file to block entertainment, news, social media, YouTube… so employees can't visit them during work hours.

4. The Hosts file gives quick access to websites

Quick access to websites

The Hosts file can also be used as a trick to open websites faster. For example, you can map the letter T to the Twitter site. Just type T and twitter.com opens right away. The syntax in the Hosts file is: 199.59.150.39 t. For cases where you need quick access to certain sites, this works as a shortcut to the web address.

5. The Hosts file strengthens security

The Hosts file can also act like a firewall on your local system. With the right Hosts file setup you can block spyware, advertisers and dangerous websites. Security goes up, keeping your data as safe as possible.

6. Test a web server with the Hosts file

In programming the Hosts file is very important and is used to test web applications. Programmers can easily run localhost, 127.0.0.1 or a localhost IP address to test and debug with the Hosts file.

See also: Setting up a local host with XAMPP and Wamp Server

7. Set up a website when you don't have a domain yet

If you don't have a domain nameyet, you can use the Hosts file temporarily to set up your website. All editing work on the website can be done through the Hosts file.

For example, if you need the domain abc.com but don't own it, you can add the IP address to the Hosts file on your computer. For IP 113.114.115 the syntax is: 113.114.115 abc.com. You then have a “live” site you can open from your computer and edit using the Hosts file.

8. Use the Hosts file to block software updates

Although it isn't a professional approach, most new IT people have used the Hosts file at some point to block software updates. You can use the Hosts file to target programs and block them easily.

How to point the Hosts file on Windows and Mac

How to point the Hosts file on Windows and Mac

The Hosts file is pointed differently on Windows and Mac. Specifically:

How to point the Hosts file on Windows

  1. Open the Hosts file at “C:WindowsSystem32driversetchosts”.
  2. Add this structure to the Hosts file: IP + space + your website name.
  3. Save the file and you've pointed the Hosts file on Windows.

How to point the Hosts file on a Mac

  1. Open Terminal and run: sudo nano /private/etc/hosts.
  2. Press Enter and type your macOS login password
  3. Enter the IP and domain in this structure: IP + space + domain
  4. When you're done, save. You've pointed the Hosts file on your Mac!

What to do when you can't save the Hosts file

In some cases the Hosts file can't be saved. You need to find the cause and fix it.

1. Why the Hosts file can't be saved

Two causes can make the Hosts file impossible to save.

  • You aren't an administrator, so you can't edit the Hosts file. It is an important file and needs permission before it can be edited.
  • An application you're running conflicts with the Hosts file. That program may be running in the background, so the Hosts file can't be saved.

2. How to fix a Hosts file that won't save

If you can't save the Hosts file, try one of these fixes:

  • Copy the Hosts file and save it to another folder: Copy the Hosts file from C:WindowsSystem32driversetc. Then save it in another folder inside C:WindowsSystem32driversetc. The Hosts file will now have a “.txt” extension; just delete the extension.
  • Find and remove the read-only attribute: Files with the read-only attribute need it removed. From the Hosts file, choose Properties. Find the read-only attribute, untick it and click OK. After removing it, try saving the Hosts file again. If it still doesn't work, try method 3.
  • Download and install extra software Notepad++: Then right-click the Hosts file and choose Edit with notepad++. Then edit the Hosts file and save. If Notepad++ shows a message while saving and you can't read English, just choose Yes and you are done.
  • Edit the Hosts file directly: Click Properties and go to the Security tab. Then click the user you're using. Choose Edit to change the user and click the Allow column on the Full control row. When that's done, click OK, then click Apply to finish editing the Hosts file.

MONA Media provides Domain, Hosting and Hosts file support, a leading provider in Vietnam

Banner Hosting

MONA Media is rated as one of the domains, Web Hosting top providers in Vietnam. For anything related to Hosting, Websites, File Host feel free to contact us for the best technical support.

MUA NGAY Hosting services at MONA, we are committed to fast loading, high stability and strong security.  CONTACT US with us through:

  • Address: 1073/23 Cach Mang Thang Tam, Ward 7, Tan Binh District, Ho Chi Minh City
  • Hotline: 1900 636 648
  • Email: info@themona.global

In particular, at MONA Media you can rent Cloud Hosting with unlimited bandwidth plans. Our cloud computing service helps you keep costs as low as possible. For anything related to web design, hosting, servers, Hosts files and more, MONA Media is happy to help as quickly as possible, with a skilled team that knows every modern technique and technology.

Frequently asked questions

Can the Hosts file be restored to its default?

To To restore the Hosts file to its default, follow these steps: In the search box in Start choose the Hosts file that is running. Then open the file in Notepad and reset it. Then save it and remove the “.txt” extension.

What are the notable programs for managing the Hosts file?

  • Host Mechanic makes it easy to add URL or an IP address to the Hosts file. You can also restore the file with just one click in the Host Mechanic app.
  • Software Hosts File Editor edits the Hosts file on your computer. Small in size, with a friendly interface and easy-to-use features.
  • Hosts file management app: Host Profiles Management. It comes in 2 versions so it can be used on both Windows and Linux.

You can also use apps such as HostMan, Easy Hosts Editor or Advanced Hosts Editor. Among them, Advanced Hosts Editor supports Vietnamese, so editing the Hosts file with it is fairly simple.

If, after reading this article, you want to learn more about what the Hosts file is or need technical support for your website, don't hesitate to Contact Work with MONA Media through Hotline 1900 636 648 . The technical specialists at MONA Media will support you as professionally as possible!

Frequently asked questions about the Hosts file

What is the Hosts file?
The Hosts file stores the IP addresses of servers and the website domain names pointed to them.
About The MONA Group: Founded in 2016, with 60+ staff, MONA has delivered 14,000+ projects with an 85% client retention rate. MONA provides website design, full-scope SEO, custom software and AI automation solutions for businesses. Consultation hotline: 1900 636 648. Explore MONA SEO services and AI tools at work.
MONA has a podcast: listen instead of readingEpisodes on AI, automation & SEO for Vietnamese businesses
Nghe ngay
About the author

CEO & Founder · The MONA

Founder of The MONA, who built a services company of 60+ staff with 14,000+ projects delivered. Khánh Hùng shares how he thinks about building systems that run themselves, automating a business, and the real lessons from delivering projects at MONA.

Views 1,5K
Rate this article 4,9/5 · 12 ratings

Professional website
design services

Own a website with a beautiful, 100% exclusive design and a lifetime warranty, with the ability
to expand features flexibly as your business grows, starting today!

Contact Mona

    MONA có riêng một Người "Bạn Thân" cho bạn - Người Account sẽ đồng hành, hỗ trợ, hướng dẫn, đặt đồ ăn cho bạn mãi mãi, từ đây về sau!
    MONA will never sell your information or send you spam
    The MONA team advising on an online education management system
    Hỏi đáp giáo dục 4.0
    Tạo cuộc hẹn miễn phí với MONA để giải đáp và tư vấn mọi thắc mắc về giải pháp số hoá ngành giáo dục
    Thời lượng cuộc hẹn
    45 Phút
    Ngày và giờ
    Thứ 2, ngày 25 tháng 12, 2023
    [9:30 - 10:15]

      Chọn ngày và giờ
      Khung giờ
      Back
      Hãy cho MONA biết bạn là ai
      0:00