.localhost is a reserved top‑level domain (TLD) defined by the Internet Engineering Task Force (IETF) in RFC 2606 ("Reserved Top Level DNS Names") and reaffirmed in RFC 6761 ("Special-Use Domain Names"). The designation reserves the name for use in local networking contexts and explicitly prevents its delegation in the public DNS hierarchy.
Purpose and Usage
- The domain is intended to resolve to the loopback addresses 127.0.0.1 (IPv4) and ::1 (IPv6), enabling software to refer to the local host without contacting external name servers.
- Operating systems, browsers, and development tools often map the name “localhost” (without the leading dot) directly to these addresses. The leading dot form, “.localhost”, can be used in configuration files or as a suffix in fully qualified domain names (e.g., example.localhost) to indicate that the name is fully qualified and should not be further qualified by a search domain.
Standards and Implementation
- RFC 2606 lists “.localhost” among four reserved TLDs, alongside “.example”, “.test”, and “.invalid”.
- RFC 6761 clarifies that queries for names ending in “.localhost” must be answered locally and must not be forwarded to external DNS resolvers.
- Major operating systems (e.g., Windows, macOS, Linux distributions) and programming language runtimes include built‑in handling for the “localhost” name, ensuring consistent loopback resolution across platforms.
Security and Compatibility Considerations
- Because the domain is reserved for local use, it is safe from hijacking or malicious redirection via the public DNS.
- Developers sometimes employ subdomains of “.localhost” (e.g., “api.localhost”) in local development environments to simulate multi‑host architectures while preserving isolation from the Internet.
Relation to Similar Names
- “localhost” (without a leading dot) is the conventional host name for the loopback interface; the dot-prefixed form is primarily a syntactic marker in DNS resolution.
- The reserved TLD “.local” is distinct and used by multicast DNS (mDNS) for zero‑configuration networking; it is not covered by the same reservations as “.localhost”.
Overall, “.localhost” serves as a standardized, reserved DNS label that guarantees loopback resolution and prevents accidental exposure to the global DNS namespace.