Web Development

Hostname: Technical Definition, Rules, and Examples

Identify network devices using hostnames. Understand RFC standards, character limits, FQDN structures, and the difference from domain names.

22.2k
hostname
Monthly Search Volume
Keyword Research

A hostname is the label assigned to a device connected to a network, used to identify it in electronic communication without requiring its numerical IP address. On the web, it typically refers to the specific server name within a domain, such as "www" or "mail," though technically any domain name assigned to a host (like "example.com" itself) can function as a hostname. For marketers, the hostname determines your site's canonical entry points, shapes subdomain strategies for international or mobile content, and controls cookie scoping for analytics tracking.

What is Hostname?

A hostname is a sequence of labels concatenated with dots, serving as the human-readable identifier for a machine on a network. [Each label must be 1 to 63 octets long, and the entire hostname must not exceed 253 ASCII characters] (RFC 1034, Section 3.1) (Microsoft Devblog). Labels may contain only ASCII letters a through z (case-insensitive), digits 0 through 9, and hyphens. [While the original specification required labels to start with an alpha character, a subsequent specification permitted them to start with digits] (RFC 952) (RFC 1123).

When combined with a domain name, the hostname creates a Fully Qualified Domain Name (FQDN). For example, in "en.wikipedia.org," "en" is the hostname, "wikipedia" is the second-level domain, and "org" is the top-level domain. Archaically, the term "nodename" was used. [Internationalized domain names are stored in DNS as ASCII strings using Punycode transcription] (RFC 3492).

Why Hostname matters

Controls canonical access points. Choosing between "www.example.com" and "example.com" as your primary hostname affects URL canonicalization and how search engines consolidate link equity.

Enables content segmentation. Hostnames like "de.onlineshop.net" or "m.example.com" create distinct entry points for regional or mobile audiences without requiring separate domains.

Defines infrastructure functions. Mail servers often use hostnames like "mail" or "imap," clarifying server roles during technical SEO audits.

Impacts tracking accuracy. Cookies set at the hostname level may not transfer across subdomains unless specifically scoped, affecting analytics continuity.

Facilitates network identification. In enterprise environments, hostnames like "BLDG001-M01" identify specific physical machines for asset management.

How Hostname works

  1. A user enters an address containing a hostname (e.g., "www.example.com") into a browser.
  2. The browser checks the local hosts file for a matching IP address. If found, it connects directly.
  3. If not found locally, a DNS resolver queries the Domain Name System to translate the hostname into an IP address.
  4. The system returns the IP address, allowing the browser to route packets to the correct server.
  5. The server receives the request and, if configured for virtual hosting, uses the hostname to determine which website content to serve.

Variations

Type Description Use case
Simple hostname Single label (e.g., "mailserver") Local network identification
FQDN Complete address including domain hierarchy (e.g., "mail.example.com.") Internet routing
Virtual hostname One of multiple hostnames mapped to a single server Hosting multiple sites on one machine
Internationalized Unicode names encoded via Punycode Global brand names with special characters

Best practices

Choose descriptive, memorable names. [General guidelines on selecting hostnames are outlined in RFC 1178] (IETF Datatracker). Names should reflect function (blog, shop) or location.

Restrict characters to letters, digits, and hyphens. Avoid underscores in web-facing hostnames. While [Chrome, Firefox, Edge, Safari, and Internet Explorer may allow underscores, cookies in IE do not work correctly if the hostname contains one] (Microsoft Developer Blog).

Observe length limits. Keep each dot-separated segment under 63 characters and the total hostname under 253 characters to ensure compatibility.

Configure Query Name Minimisation. For privacy compliance, [enable Query Name Minimisation in DNS software, available by default in BIND 9.14.0] (ISC Blog).

Document default domains. Configure operating systems to automatically qualify short hostnames with default domains to prevent internal resolution failures.

Common mistakes

Mistake: Confusing hostnames with subdomains. In "blog.www.example.com," "blog" is a subdomain under the "www" hostname. The hostname remains the leftmost label specifically associated with the machine. Fix: Treat the leftmost label as the hostname for server identification purposes, regardless of how many subdomain levels exist to its right.

Mistake: Using underscores in hostnames intended for web tracking. While DNS standards reserve underscores for special records (like SRV records), using them in hostnames breaks cookie functionality in some browsers. Fix: Use hyphens to separate words (e.g., "mail-server" not "mail_server").

Mistake: Exceeding label length limits. Creating segments longer than 63 octets causes validation failures in standards-compliant systems. Fix: Keep each dot-separated portion under 63 characters.

Mistake: Changing hostnames without updating DNS records. Altering a server's hostname without reflecting the change in A records, CNAMEs, or analytics configuration disconnects tracking and breaks inbound links. Fix: Update all DNS records, server configs, and analytics property settings simultaneously when changing hostnames.

Examples

Standard web server: In "www.ionos.com," "www" is the hostname identifying the web server.

Regional targeting: "de.onlineshop.net" uses "de" as the hostname to serve German-language content, avoiding the need for a separate .de TLD.

Enterprise asset: "BLDG001-M01" identifies a specific machine in a corporate network, following physical asset naming conventions.

Mobile entry point: "m.example.com" designates a hostname dedicated to mobile device access.

Hostname vs Domain Name

Understanding the distinction prevents configuration errors.

Aspect Hostname Domain Name
Identifies Specific device or server Administrative realm within DNS
Position Leftmost label (or full FQDN when assigned to host) The parent structure (SLD.TLD)
Example "www" in www.example.com "example.com"
Resolution Maps to a specific IP address Encompasses multiple host records

Rule of thumb: If the name resolves to a specific server's IP and identifies that individual machine's function (web, mail, ftp), it is functioning as a hostname.

FAQ

What is the difference between a hostname and a domain name? A hostname identifies a specific device, while a domain name identifies a realm within the DNS hierarchy. Any domain name assigned to a host (with an associated IP address) can serve as a hostname. For example, both "en.wikipedia.org" and "wikipedia.org" can be hostnames because both can resolve to IP addresses, though "en" is the specific hostname within the larger domain.

Is "www" a hostname or a subdomain? It functions as both. In the FQDN "www.example.com", "www" is technically the hostname identifying the web server. However, because it sits left of the domain name, it is also structurally a subdomain. The distinction matters for server configuration: the hostname identifies the specific machine or virtual host receiving the request.

Can I use underscores in my hostname? Standards prohibit underscores in hostnames, reserving them for special DNS records like SRV records. While modern browsers may resolve hostnames containing underscores, [Internet Explorer handles cookies incorrectly for such names] (Microsoft Developer Blog). For broad compatibility, use hyphens instead.

How long can a hostname be? [Each label (dot-separated segment) must be between 1 and 63 octets, and the complete hostname must not exceed 253 ASCII characters] (RFC 1034) (Microsoft Devblog).

Can one computer have multiple hostnames? Yes. A single host can respond to multiple hostnames through virtual host configurations or by having multiple DNS records (A or CNAME) pointing to its IP address. This allows one server to host multiple websites (e.g., "blog.example.com" and "shop.example.com") on the same machine.

How do I find my computer's hostname on Windows? Open Command Prompt and type hostname, then press Enter. [Alternatively, the environment variable %COMPUTERNAME% displays the name in uppercase] (Microsoft Learn). On macOS, check "About This Mac" under System Settings. On Linux, use the terminal command hostname.

What is a Fully Qualified Domain Name (FQDN)? An FQDN is the complete hostname including all domain levels up to and including the top-level domain (TLD) and the root domain (represented by a trailing dot). For example, "mail.example.com." is an FQDN where "mail" is the hostname, "example" is the second-level domain, and "com" is the TLD.

Start Your SEO Research in Seconds

5 free searches/day • No credit card needed • Access all features