You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Please consider adding support for validating hostnames against RFC 1123, which defines valid DNS hostnames. This would be helpful for use cases where strict compliance is needed (e.g., infrastructure tools, domain name validation, security filters).
✅ RFC 1123 Requirements Summary
RFC 1123 hostnames must:
Only include letters (A–Z, a–z), digits (0–9), and hyphens (-)
Not begin or end with a hyphen
Be ≤ 253 characters total
Have each label ≤ 63 characters
Cannot contain underscores or other special characters
“The syntax of a legal Internet host name was specified in RFC-952.
One aspect of host name syntax is hereby changed: the restriction on the first character is relaxed to allow either a letter or a digit.
Host software MUST support this more liberal syntax.
Host software MUST handle host names of up to 63 characters and SHOULD handle host names of up to 255 characters.”
— RFC 1123 § 2.1
✅ Summary of Requirements Derived from RFC 1123
Rule
Defined or Modified in RFC 1123
Notes
Hostnames may begin with a letter or digit
✅ RFC 1123 § 2.1
RFC 1123 explicitly relaxes RFC 952 (which required starting with a letter).
Hostnames use letters, digits, and hyphens only (LDH rule)
✅ Inherited from RFC 952, reaffirmed by RFC 1123
RFC 1123 didn’t change the allowed character set.
No leading or trailing hyphen
✅ From RFC 952 § 1, still in effect
RFC 1123 doesn’t alter this restriction.
Label length ≤ 63 characters
✅ RFC 1123 § 2.1
The RFC requires software to handle labels up to 63 characters.
Full name ≤ 255 characters
✅ RFC 1123 § 2.1
“SHOULD handle host names of up to 255 characters.”
All of the requirements listed here are already enforced by hostname() and domain() on current master: letters, digits and hyphens only; no leading or trailing hyphen; labels up to 63 characters; the whole name up to 253 (#461); no underscores unless rfc_2782 is set; and a label may start with a digit, which is the relaxation RFC 1123 section 2.1 introduced. #493 adds regression tests for these limits. Please reopen with a failing example if you find a case that is accepted or rejected incorrectly.
Activity
nandgator commentedon Sep 27, 2025
This document has had many revisions. Please provide references to these requirements based on updated documents.
Maxk-Intezer commentedon Oct 5, 2025
🧩 RFC 1123 Hostname Requirements Summary
📄 Source: RFC 1123 – Section 2.1 (Host Names and Numbers)
✅ Summary of Requirements Derived from RFC 1123
nandgator commentedon Oct 10, 2026
All of the requirements listed here are already enforced by
hostname()anddomain()on current master: letters, digits and hyphens only; no leading or trailing hyphen; labels up to 63 characters; the whole name up to 253 (#461); no underscores unlessrfc_2782is set; and a label may start with a digit, which is the relaxation RFC 1123 section 2.1 introduced. #493 adds regression tests for these limits. Please reopen with a failing example if you find a case that is accepted or rejected incorrectly.