hosts file
termA local text file that maps host names to IP addresses, descended from HOSTS.TXT, the single host table the early network used before DNS.
Before DNS, every host fetched the NIC's HOSTS.TXT by FTP, and RFC 1034 names the cost, growing with the square of the number of hosts, among the reasons DNS was built. The local file survives as /etc/hosts and the Windows hosts file, and an entry in it overrides DNS wherever the system consults it first.
It began in January 1974, when RFC 608 had the NIC publish an ASCII file of host names and addresses, HOSTS.TXT, regenerated weekly or as the situation warranted. RFC 952 (October 1985), by Harrenstien, Stahl and Feinler, is the final specification: NET, GATEWAY, HOST and DOMAIN entries in colon-separated fields, fetched by FTP from SRI-NIC or through the hostname server. RFC 1034 records why it ended: distribution grew with the square of the number of hosts, and organisations had to wait for the NIC to make their changes visible.
Today's file holds one line per address: the address, the canonical name, then aliases, IPv4 or IPv6, with # starting a comment. On Windows it sits in %WinDir%\System32\Drivers\Etc, typically C:\Windows\System32\drivers\etc. Whether it is read before DNS is configuration, not protocol: on glibc systems the hosts line of /etc/nsswitch.conf lists the sources in order, files meaning /etc/hosts, and the manual's own example puts dns first.
A forgotten entry keeps one machine on an old address while every other follows DNS, and Microsoft lists a modified hosts file as a cause of connectivity problems. getent hosts resolves a name in the nsswitch order, as the C library does, while dig asks name servers directly, so when the two disagree the file or the switch order is the first suspect.
Also known as: HOSTS.TXT, host table, /etc/hosts
Sources
- RFC 952, DoD Internet Host Table Specification, October 1985: Introduction, Location of the Standard DoD Online Host Table, Syntax and Conventions (read 2026-10-19)
- RFC 1034, Domain names - concepts and facilities, November 1987: section 2.1 (read 2026-10-19)
- nsswitch.conf(5), Linux manual page (man-pages 6.19), man7.org rendering of 9 September 2026: DESCRIPTION and FILES (read 2026-10-19)
- Microsoft Support, How to reset the Hosts file back to the default, 13 February 2026: What's the Hosts file and Reset your hosts file (read 2026-10-19)