Skip to the content
Start free

Hostname

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 between the https:// and the first slash. Browsers, crawlers and email systems use it to find the right server through DNS.

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 says it holds the domain name or 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, here a country code TLD.

Is a hostname the same as a domain name? #

Not quite. A 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: 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? #

The rules come from old internet standards that still apply.

  • Letters, digits and hyphens. RFC 1035 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 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.

Search engines treat each hostname as its own site in several ways.

  • robots.txt is per host. Google’s robots.txt guide 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.
  • Crawl budget is per host. Google’s crawl budget guide treats each hostname as a separate site, so www.example.com and code.example.com are crawled on their own terms. See crawl budget.
  • Duplicates across hosts. If the same page loads on example.com and www.example.com, that is duplicate content. Google’s guide to consolidating duplicate URLs says to pick one as canonical and redirect the others to it. Redirects are its strongest signal, then a 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. Domain properties are verified with a DNS record.

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 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 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 are told apart from fakes.

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 such as A, AAAA and CNAME give the answer.
  3. It connects to that server. With HTTPS, the server must show an SSL certificate that names this hostname.
  4. It sends the hostname again in the Host header. MDN’s Host header page says this header must be sent in all HTTP/1.1 requests, and a server may answer 400 Bad Request if it is missing. One server can then run many sites, picking each one by name.

A CDN works the same way: your hostname points at the CDN, which reads the Host header and fetches from your origin server.

Common mistakes #

  • Both www and non-www answer with 200. Pick one and send the other with a 301 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.
  • Changing host without a plan. Moving from one hostname to another is a site move; see moving a website without losing traffic.

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 and redirect chains.

How to check it #

  1. Split any address into its parts with our URL Parser. For names in other alphabets, use the Punycode Converter, and test the spelling with the Domain Name Validator.
  2. See where each hostname points with our DNS Lookup and Website IP Lookup.
  3. Run every variant through our Redirect Checker to count the hops.
  4. Check the certificate covers each name with our SSL Checker.
  5. Read the status code and headers with our HTTP Header Checker, and the canonical with our Canonical Checker.
  6. Open /robots.txt on each host, or use our Robots.txt Checker.
  7. To confirm a crawler is real, paste its IP into Verify AI Bot.

Questions #

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? #

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? #

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? #

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

Sources #

Updated 24 November 2026 by URSY.

Cite this page: Hostname. URSY. Updated 24 November 2026. https://ursy.com/wiki/hostname/ · Section links

Tools for this

All 871 wiki entries, A to Z →