---
title: "Hostname"
description: "A hostname is the name of one server or service, like www.example.com. Learn the rules, why each host is its own site to Google, and how to check yours."
url: https://ursy.com/wiki/hostname/
updated: 2026-11-24T23:29:43+00:00
publisher: URSY (https://ursy.com/)
cite: Name URSY and link https://ursy.com/wiki/hostname/
---

# Hostname

> A hostname is the name of one server or service, like www.example.com. Learn the rules, why each host is its own site to Google, and how to check yours.

**A hostname is the name of one machine or service on the internet, written as words joined by dots, such as www.example.com or shop.example.co.uk.** It is the part of a [URL](https://ursy.com/wiki/url/) between the https:// and the first slash. Browsers, crawlers and email systems use it to find the right server through [DNS](https://ursy.com/wiki/dns/).

## What is a hostname? {#what-is-a-hostname}

Take the address https://www.example.co.uk:8443/kettles/?sort=price. The scheme is https. The hostname is www.example.co.uk. The port is 8443. The path is /kettles/ and the rest is a query. MDN’s page on the [URL hostname property](https://developer.mozilla.org/en-US/docs/Web/API/URL/hostname) says it holds the domain name or [IP address](https://ursy.com/wiki/ip-address/) of the URL, without the port. It also shows that names in other alphabets are turned into a plain ASCII form called Punycode.

A hostname is built from labels. In www.example.co.uk there are 4 labels: www, example, co and uk. The last one is the [top-level domain](https://ursy.com/wiki/top-level-domain/), here a [country code TLD](https://ursy.com/wiki/cctld-country-code-top-level-domain/).

## Is a hostname the same as a domain name? {#is-a-hostname-the-same-as-a-domain-name}

Not quite. A [domain name](https://ursy.com/wiki/domain-name/) is the name you register, such as example.co.uk. A hostname points at one service under it. The bare domain can be a hostname too, and so can every [subdomain](https://ursy.com/wiki/subdomain/): www.example.co.uk, blog.example.co.uk and m.example.co.uk are 3 hostnames on 1 domain. A “host” in a URL can also include the port, while the hostname never does. MDN shows this with example.com:8080, where the host is example.com:8080 and the hostname is example.com.

## What are the rules for a valid hostname? {#what-are-the-rules-for-a-valid-hostname}

The rules come from old internet standards that still apply.

- **Letters, digits and hyphens.**  [RFC 1035](https://www.rfc-editor.org/rfc/rfc1035) says labels start with a letter, end with a letter or digit, and use only letters, digits and hyphens inside.
- **Digits may come first.**  [RFC 1123](https://www.rfc-editor.org/rfc/rfc1123) relaxed the first-character rule to allow a letter or a digit, so a label such as 4you is fine.
- **Length.**  RFC 1035 sets labels at 63 octets or less and whole names at 255 octets or less.
- **Case does not matter.**  RFC 1035 says comparisons are case-insensitive, so WWW.Example.COM and www.example.com are the same name.
- **No underscores or spaces**  in a web hostname that people type.

## Why does it matter for search? {#why-does-it-matter-for-search}

[Search engines](https://ursy.com/wiki/search-engine/) treat each hostname as its own site in several ways.

- **robots.txt is per host.**  [Google](https://ursy.com/wiki/google/)’s [robots.txt guide](https://developers.google.com/search/docs/crawling-indexing/robots/robots_txt) says the rules apply only to the host, protocol and port where the file sits. A file on www.example.com does not cover example.com. See [robots.txt](https://ursy.com/wiki/robots-txt/).
- **Crawl budget is per host.**  Google’s [crawl budget guide](https://developers.google.com/search/docs/crawling-indexing/large-site-managing-crawl-budget) treats each hostname as a separate site, so www.example.com and code.example.com are crawled on their own terms. See [crawl budget](https://ursy.com/wiki/crawl-budget/).
- **Duplicates across hosts.**  If the same page loads on example.com and www.example.com, that is [duplicate content](https://ursy.com/wiki/duplicate-content/). Google’s guide to [consolidating duplicate URLs](https://developers.google.com/search/docs/crawling-indexing/consolidate-duplicate-urls) says to pick one as canonical and redirect the others to it. Redirects are its strongest signal, then a [canonical tag](https://ursy.com/wiki/canonical-tag/), then the sitemap.
- **Search Console.**  A Domain property covers every subdomain and both protocols. A URL-prefix property covers only addresses that start with that exact host and protocol, according to [Search Console Help](https://support.google.com/webmasters/answer/34592). Domain properties are verified with a DNS record.

## Why does it matter for AI answers? {#why-does-it-matter-for-ai-answers}

AI crawlers obey the same per-host robots.txt files, so a rule set on the www host does nothing for the bare one. An [AI crawler](https://ursy.com/wiki/ai-crawler/) that meets 2 hostnames with the same text may also quote the wrong one. One clean hostname gives assistants one address to cite. When you check who is visiting, the hostname matters again: a [reverse DNS check](https://ursy.com/wiki/reverse-dns-bot-check/) turns the visitor’s IP address back into a hostname, such as one ending in googlebot.com, and then looks that name up again to confirm it. That is how [verified bots](https://ursy.com/wiki/verified-bots/) are told apart from fakes.

## How does it work? {#how-does-it-work}

1. You type a URL. The browser pulls out the hostname.
2. It asks DNS for the matching address. [DNS records](https://ursy.com/wiki/dns-records/) such as A, AAAA and CNAME give the answer.
3. It connects to that server. With HTTPS, the server must show an [SSL certificate](https://ursy.com/wiki/ssl-certificate/) that names this hostname.
4. It sends the hostname again in the Host header. MDN’s [Host header page](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Host) says this header must be sent in all [HTTP](https://ursy.com/wiki/http/)/1.1 requests, and a server may answer [400 Bad Request](https://ursy.com/wiki/400-bad-request/) if it is missing. One server can then run many sites, picking each one by name.

A [CDN](https://ursy.com/wiki/cdn/) works the same way: your hostname points at the CDN, which reads the Host header and fetches from your [origin server](https://ursy.com/wiki/origin-server/).

## Common mistakes {#common-mistakes}

- **Both www and non-www answer with 200.**  Pick one and send the other with a [301 redirect](https://ursy.com/wiki/301-vs-302-redirect/).
- **A certificate that misses one host.**  The bare domain works but www shows a warning, or the other way round.
- **robots.txt on one host only.**  Rules are copied to the www host but the shop subdomain has none.
- **A staging host left open.**  dev.example.com gets crawled and indexed next to the real site.
- **Links that mix hosts.**  Menus point at the non-preferred host, so every click goes through a [redirect](https://ursy.com/wiki/redirect/).
- **Changing host without a plan.**  Moving from one hostname to another is a site move; see [moving a website without losing traffic](https://ursy.com/wiki/move-a-website-without-losing-traffic/).

## A worked example {#a-worked-example}

A small UK shop runs on example.co.uk. We test 4 starting addresses.

| Address typed | What happens | Verdict |
| --- | --- | --- |
| https://www.example.co.uk/ | 200, the real home page | Preferred host |
| https://example.co.uk/ | 301 to https://www.example.co.uk/ | Good |
| http://example.co.uk/ | 301 to https://example.co.uk/, then 301 again | Works, but 2 hops: point it straight at the www host |
| https://shop.example.co.uk/ | 200, same home page | Duplicate: redirect it or give it its own content |

The fix is a single rule that sends every variant straight to https://www.example.co.uk/ in 1 hop. See [HTTPS vs HTTP](https://ursy.com/wiki/https-vs-http/) and [redirect chains](https://ursy.com/wiki/redirect-chain/).

## How to check it {#how-to-check-it}

1. Split any address into its parts with our [URL Parser](https://ursy.com/webmaster-tools/url-parser/). For names in other alphabets, use the [Punycode Converter](https://ursy.com/webmaster-tools/punycode-converter/), and test the spelling with the [Domain Name Validator](https://ursy.com/webmaster-tools/domain-name-validator/).
2. See where each hostname points with our [DNS Lookup](https://ursy.com/webmaster-tools/dns-lookup/) and [Website IP Lookup](https://ursy.com/webmaster-tools/website-ip-lookup/).
3. Run every variant through our [Redirect Checker](https://ursy.com/redirect-checker/) to count the hops.
4. Check the certificate covers each name with our [SSL Checker](https://ursy.com/ssl-checker/).
5. Read the status code and headers with our [HTTP Header Checker](https://ursy.com/http-header-checker/), and the canonical with our [Canonical Checker](https://ursy.com/canonical-checker/).
6. Open /robots.txt on each host, or use our [Robots.txt Checker](https://ursy.com/robots-txt-checker/).
7. To confirm a crawler is real, paste its IP into [Verify AI Bot](https://ursy.com/verify-ai-bot/).

## Questions {#questions}

### Should I use www or not? {#should-i-use-www-or-not}

Either works. What matters is choosing one and redirecting the other to it.

### Is a subdomain a separate site to Google? {#is-a-subdomain-a-separate-site-to-google}

For robots.txt and crawl budget, yes. Each hostname has its own file and its own crawl limits.

### Can a hostname be an IP address? {#can-a-hostname-be-an-ip-address}

Yes. MDN says the hostname can be a domain name or an IP address. Google says a robots.txt on an IP applies only to that IP as the hostname.

### Do capital letters matter? {#do-capital-letters-matter}

No, not in the hostname. The path after it can be case-sensitive, so keep URLs in lower case.

## Related words {#related-words}

- [Domain name](https://ursy.com/wiki/domain-name/)
- [Subdomain](https://ursy.com/wiki/subdomain/)
- [DNS](https://ursy.com/wiki/dns/)
- [URL](https://ursy.com/wiki/url/)
- [User agent](https://ursy.com/wiki/user-agent/)

## Sources {#sources}

- [MDN: URL hostname property](https://developer.mozilla.org/en-US/docs/Web/API/URL/hostname), checked 24 November 2026
- [MDN: Host header](https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Host), checked 24 November 2026
- [RFC 1035: Domain names, implementation and specification](https://www.rfc-editor.org/rfc/rfc1035), checked 24 November 2026
- [RFC 1123: Requirements for Internet Hosts](https://www.rfc-editor.org/rfc/rfc1123), checked 24 November 2026
- [Google Search Central: How Google interprets the robots.txt specification](https://developers.google.com/search/docs/crawling-indexing/robots/robots_txt), checked 24 November 2026
- [Google Search Central: Crawl budget management for large sites](https://developers.google.com/search/docs/crawling-indexing/large-site-managing-crawl-budget), checked 24 November 2026
- [Google Search Central: How to specify a canonical URL](https://developers.google.com/search/docs/crawling-indexing/consolidate-duplicate-urls), checked 24 November 2026
- [Search Console Help: Add a website property](https://support.google.com/webmasters/answer/34592), checked 24 November 2026

*Updated 24 November 2026 by URSY.*
