Domain Name vs URL vs Hostname

Run a Speed Test

People use domain, URL, host, and hostname interchangeably in casual speech. Computers do not. Knowing the difference makes DNS, certificates, redirects, analytics, and troubleshooting much less slippery.

Anatomy of a URL

A URL (Uniform Resource Locator) is a complete address for a resource on the internet. Every part carries a specific meaning and is handled by a different layer of the system.

PartExampleMeaning
SchemehttpsProtocol or access method
Authoritywww.example.com:443Host and optional port
Hostnamewww.example.comName used to find the server
Domainexample.comRegistered domain under a TLD
Port443Service port (often omitted when default)
Path/guides/pageResource on the server
Query?q=test&lang=enParameters sent to the application
Fragment#sectionClient-side anchor, never sent to the server

Browsers parse a URL left to right. The scheme tells the browser which protocol to use. The authority (host plus optional port) tells the TCP stack where to connect. The path, query, and fragment are sent to the server after the connection is established — except the fragment, which stays in the browser and is used only for in-page navigation.

Domain Name

A domain name is a name in the DNS hierarchy. example.com is a domain. So is shop.example.com, because it is a subdomain under example.com. In business language, "the domain" often means the registered second-level domain plus its TLD, such as example.com. The TLD is the rightmost label: .com, .org, .io, or a country code such as .uk or .de.

Hostname

A hostname is the specific name used to identify a host or service endpoint. In a URL like https://www.example.com/products, DNS resolves www.example.com, not the path. The hostname may be the apex domain (example.com), a subdomain (api.example.com), or a local machine name. On a corporate network, hostnames like fileserver or printer-floor3 are valid within that domain context without being routable on the public internet.

FQDN vs Relative Hostnames

A Fully Qualified Domain Name (FQDN) specifies the complete DNS path from the hostname to the root. www.example.com. (note the trailing dot representing the DNS root) is an FQDN. A relative hostname like fileserver without a domain suffix is only meaningful within a local DNS search domain. Browsers and most tools append the configured DNS search domain when resolving short names, which can cause subtle failures if the search domain is wrong or missing. In DNS configuration files, the trailing dot is significant and distinguishes an FQDN from a name that will have the zone name appended.

How Browsers Parse URLs

When you type a URL into a browser or click a link, the browser applies the WHATWG URL Standard to parse it. The scheme determines the default port (80 for http, 443 for https). If a port is present in the URL, it overrides the default. The host portion is normalized to lowercase. The path is percent-encoded if it contains characters not allowed in a URL. The query string is left as-is except for encoding of unsafe characters. The fragment is stripped before the HTTP request is sent — the server never sees it. Browsers also handle schemes beyond http and https, such as ftp://, mailto:, and custom app schemes.

Punycode and Internationalized Domain Names

DNS labels are technically restricted to ASCII letters, digits, and hyphens. Internationalized domain names (IDNs) containing characters from other scripts — Arabic, Chinese, Cyrillic, accented Latin — are encoded using Punycode before being sent to DNS. münchen.de becomes xn--mnchen-3ya.de in DNS. Browsers display the human-readable form in the address bar, but the actual DNS lookup uses the Punycode form. This matters for security: visually similar characters from different Unicode scripts can be used to create spoofed domain names that look identical to legitimate ones.

URL Encoding

URLs are restricted to a safe subset of ASCII characters. Any character outside that set must be percent-encoded: each byte is written as % followed by two hexadecimal digits. A space becomes %20, a forward slash in a query value becomes %2F, and so on. This is why search results often show long strings of %xx sequences in the address bar. Path segments, query parameters, and fragment identifiers each have slightly different rules about which characters must be encoded.

The Origin Concept in Browsers

Browsers enforce security boundaries using the concept of origin, which is defined as the combination of scheme, host, and port. Two pages share an origin only if all three components match exactly. https://example.com and http://example.com are different origins because the scheme differs. https://example.com and https://api.example.com are different origins because the host differs. https://example.com and https://example.com:8443 are different origins because the port differs.

Why Different Ports Are Different Origins (CORS)

Cross-Origin Resource Sharing (CORS) is the browser mechanism that controls whether a web page served from one origin can make requests to a different origin. Because port is part of the origin, a front-end app running on http://localhost:3000 is a different origin from an API on http://localhost:8080, even though both are on the same machine. The browser will block the cross-origin fetch unless the API responds with appropriate Access-Control-Allow-Origin headers. This is a common stumbling block in local development, and it is rooted in the strict definition of origin, not a bug.

Why It Matters

  • DNS records map hostnames and domain names, not full URLs. A CNAME or A record points to a hostname, not a path.
  • TLS certificates must match the hostname (or use a wildcard subdomain). The path is irrelevant to certificate validation.
  • Redirects can change the URL, path, or scheme without changing the registered domain.
  • Analytics tools may group sessions by hostname, by full URL, or by path — understanding the distinction avoids misreading reports.
  • Hosts file entries override hostname resolution, not paths or schemes.
  • CORS and cookie scope both depend on origin and hostname, not on the full URL including path.

Frequently Asked Questions

Is a URL the same as a domain name?

No. A URL is the full address, such as https://www.example.com/path. The domain or hostname is only one part of that URL.

What does DNS resolve: URL or hostname?

DNS resolves names such as hostnames or domain names to records. It does not resolve the full URL path, query string, or fragment.

Is www a domain or hostname?

www is usually a hostname label or subdomain under a domain, such as www.example.com.

Related Guides

More From This Section