Validate hostname

Check RFC 1123 hostname labels, lengths, and allowed hyphens.

freeworks offlinenothing uploaded
ToolHostname Validator
Input
Output
Put this on your own site

The frame below runs the same code as this page, in the reader's own browser. Nothing is sent to us, and nothing is sent to you.

Pick a dark background and the text and panels follow it, so the frame stays readable on a dark page.

Preview

How it works

The lowercased hostname is split into labels, checked against 63-character label and 253-character total limits, and each label must start and end with a letter or digit while allowing internal hyphens. A single label is allowed because no public TLD is required.

  • Numeric-leading labels are permitted by RFC 1123.
  • Lowercasing follows DNS case-insensitivity.

Worked example

Valid Hostname
Validate a well-formed hostname
Input
											web-server-01.us-east.example.com
										
Output
												Valid hostname: web-server-01.us-east.example.com
											

When to use this

Server configs, Kubernetes services, and TLS DNS names validate hostnames.

Edge cases

  • A label ending in a hyphen is invalid.
  • localhost is valid as a single host label here.
  • An underscore fails the host pattern despite some discovery systems using it.

References