The hosts file: The ARPANET relic that still rules your connection

Have you ever wondered how your computer knows that localhost is 127.0.0.1? Or why, in the age of the cloud, a file called hosts still exists in your operating system? The answer takes us on a journey to the past, to the days when the internet was a small network called ARPANET, and system administrators manually loaded a text file to enable computers to communicate.

Today, our internet-connected devices rely on DNS (Domain Name System), a distributed system that translates domain names like “wikipedia.org” into numeric IP addresses (e.g., 185.15.58.224). To communicate with other devices online, we need to know this identifier—the IP address.

If we manually query a DNS server (something our apps do transparently for us constantly), we’d get something like this:

But this wasn’t always the case. In the 1970s and early 1980s, before DNS, computers on ARPANET depended on a file called HOSTS.TXT. Maintained manually by the Stanford Research Institute (SRI), this file acted as a global phonebook. It listed hostnames (equivalent to modern domains, like “UCLA”) and their IP addresses. Every computer had to periodically download this file from a central server to know how to contact others on the network.

Unsurprisingly, this required constant updates. Whenever someone new joined the network—say, a university added a new computer—they had to notify SRI. The HOSTS.TXT file would be updated, and everyone else had to re-download it.

The system worked… until the network grew.

Maintaining a centralized file became unsustainable. Name conflicts were frequent, updates required manual effort, and delays were inevitable.

So, in 1983, Paul Mockapetris proposed a revolutionary solution: DNS, a distributed system that automated name resolution through a hierarchy of servers, eliminating reliance on a single file.

But curiously, DNS didn’t completely erase the hosts file. For compatibility and flexibility, modern operating systems still include a local hosts file—like /etc/hosts on Linux or hosts on Windows (usually in *C:\Windows\System32\drivers\etc*). You can edit this file manually with the right permissions, such as using sudo in Linux or running Notepad as an administrator in Windows.

Sometimes, we need to temporarily bypass DNS—and that’s where the hosts file shines. For instance, in web development, it allows testing applications with custom domains without touching public DNS records. It doubles as a troubleshooting tool, letting us rule out DNS issues by manually mapping domains directly in the file. It also helps assign friendly names to devices on a local network, like giving your home server a memorable alias. Or even block unwanted domains—redirecting pesky ads or tracking sites to 127.0.0.1, effectively stopping them in their tracks.

The hosts file is a living fossil, a relic from the pre-DNS era. Yet we’ve repurposed it into a versatile tool, ensuring its survival. For now, it’s here to stay—and shows no signs of retiring.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top