What is the maximum length of the 'name' part in a domain?
I'm referring to the google
in http://www.google.com
. How long can the google
part be without what's before and after it?

- 6,159
- 23
- 88
- 141
-
3Since stack and wikipedia keep referencing each other, I found some good summaries here: http://blog.sacaluta.com/2011/12/dns-domain-names-253-or-255-bytesoctets.html and http://blogs.msdn.com/b/oldnewthing/archive/2012/04/12/10292868.aspx – goodeye Dec 10 '13 at 16:07
5 Answers
Each label may contain up to 63 characters.

- 2,749
- 4
- 33
- 43
-
7yes, technically called labels and it may contain up to 63 characters. Source: http://en.wikipedia.org/wiki/Domain_Name_System – Prakash Jan 18 '13 at 16:17
-
-
3Part of the reasoning behind 63 (vs 255) is for packet compression. a 1,1 in the first 2 bits of an 8 bit length indicates a pointer to a previous label (which _should_actually_ make the limit 191) Some poor implementation that checked those bits as individual flags is probably the reason for 63 char limit. – technosaurus Nov 16 '14 at 15:25
-
1Take in consideration that domains can be nested, for example: `www.group-of-hosts.department.example.com` - So each label may be 63 chars long and the full domain without `www.` and `.com` could be longer, as in this case it would be `group-of-hosts.department.example` - This may be longer than 63. – Xavi Montero Apr 13 '17 at 19:50
-
4from same wiki source: `The full domain name may not exceed the length of 253 characters in its textual representation.` So i assume it's safe to use 255 length varchar to save domain name while using sql db. – Lukas Liesis Jun 16 '17 at 07:38
"URI producers should use names that conform to the DNS syntax, even when use of DNS is not immediately apparent, and should limit these names to no more than 255 characters in length."
https://www.rfc-editor.org/rfc/rfc3986
"The DNS itself places only one restriction on the particular labels that can be used to identify resource records. That one restriction relates to the length of the label and the full name. The length of any one label is limited to between 1 and 63 octets. A full domain name is limited to 255 octets (including the separators)."
The full domain name may not exceed a total length of 253 characters in its external dotted-label specification.
http://en.wikipedia.org/wiki/Domain_Name_System
If you are getting anywhere close to 253 characters, I think you should look for a shorter domain name...

- 1,576
- 1
- 10
- 18
-
4
-
1Obviously if your domain name is approaching 253 chars it should be shorter ... but have you heard of this thing called ... the internet? People are crazy there. You can't imagine some of the things they come up with. – Williams May 11 '21 at 04:21
TLDR Answer
Use these limits:
Labels:
61
octets.Names:
253
octets.
Many applications will work even if you exceed these limits (like Gmail), but there are many older applications that will not.
Source
RFC1035: Domain Names - Implementation And Specification (published November 1987), an accepted Internet Standard, gives the following limits to subdomains and to the entire domain length when viewed in a browser...
Various objects and parameters in the DNS have size limits. They are listed below. Some could be easily changed, others are more fundamental.
labels
63
octets [bytes/characters] or lessnames
255
octets [bytes/characters] or less
The working level of these are:
- Labels:
61
octets. - Names:
253
octets.
That's because RFC821
(published August 1982) defines emails in the format of user@domain.com
, and the smallest value for user
would be one character. That leaves one character for @
, and then you only have 253
characters left for the domain.com
part.
This was reconfirmed numerous times...
RFC2181: Clarifications to the DNS Specification (published July 1997) : Only a proposed standard. "A full domain name is limited to 255 octets (including the separators)."
RFC3986: Uniform Resource Identifier (URI): Generic Syntax (published January 2005) : Accepted Internet standard. "URI producers should use names that conform to the DNS syntax, even when use of DNS is not immediately apparent, and should limit these names to no more than 255 characters in length."
RFC5321: Simple Mail Transfer Protocol (published October 2008) : Only a proposed standard. This RFC gives the max length of label or subdomains to be
64
, one more than the others of63
. I recommend sticking with63
. "The maximum total length of a domain name or number is 255 octets."
You may have 63 characters per label (or subdomain) and 255 characters per name (this includes the TLD).
Notice that it gives the definition in octets. That's because it's looking at physical bytes, not literal bytes. For instance, \.
is interpreted as .
(one literal byte), because the \
escapes it, but it is encoded as \.
(two physical bytes). These octet limits are physical byte limits.

- 1
- 1

- 18,769
- 10
- 104
- 133
As a demonstration, this website has a 63 characters domain name, the maximum allowed: http://63-characters-is-the-longest-possible-domain-name-for-a-website.com

- 81
- 1
- 1
-
5The site is down but here is the archive: https://web.archive.org/web/20160308231823/http://63-characters-is-the-longest-possible-domain-name-for-a-website.com – styfle Mar 29 '18 at 20:27