A hostname is the human-readable name assigned to a device (or host) on a network — a more memorable alternative to using its IP address.

Think of It Like:

Hostname = Contact name in your phone IP address = Phone number

You don’t remember everyone’s phone number. Similarly, you use hostnames like google.com or backend-service instead of IPs like 142.250.182.206.

Types of Hostnames

1. Domain Names (FQDN)

  • Fully Qualified Domain Name
  • Example: www.example.com
    • www → subdomain
    • example → domain
    • .com → TLD (top-level domain)

2. Local Hostnames

  • Set within a local network or system
  • Examples:
    • localhost → refers to 127.0.0.1
    • my-pc.local → your laptop’s local name on LAN

How Hostnames Work

  1. You type www.google.com
  2. The system uses DNS (Domain Name System) to resolve it to an IP address.
  3. It sends a request to that IP over the internet.

Hostname in System Design

Use CaseDescription
Service discoveryApps use hostnames like auth-service instead of hardcoded IPs.
DNS-based routingHostnames route traffic to different services (e.g., api.example.com, shop.example.com).
KubernetesPods/services get auto-generated hostnames.
Load balancingDNS-based load balancers use hostnames to distribute traffic.
SSL/TLSCertificates are tied to hostnames, not IPs.

Example: /etc/hosts file

127.0.0.1   localhost
192.168.1.10   my-laptop

You can use this to override hostname resolution manually.

Important Points

  • A hostname maps to an IP — not the other way around.
  • A hostname can map to multiple IPs (for redundancy/load balancing).
  • You can assign a hostname to a static or dynamic IP (via dynamic DNS).