39

Out of curiosity, does anyone know what's the maximum length (in characters) for a domain name?

Let's exclude the http://www.

I know the maximum length of an url is about 2000 chars. But here I'm more ineterested in just the domain part or the url.

On Wikipedia they say: "The full domain name may not exceed a total length of 253 characters in its external dotted-label specification." But what does that mean?

Marco Demaio
  • 6,490
  • 5
  • 33
  • 41
  • Since 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
  • 1
    Demonstration: the following website has a 63 characters domain name: http://63-characters-is-the-longest-possible-domain-name-for-a-website.com – Pixels Hunter Nov 12 '15 at 05:15

2 Answers2

53
  1. 253 characters is the maximum length of full domain name, including dots: e.g. www.example.com = 15 characters.

  2. 63 characters in the maximum length of a "label" (part of domain name separated by dot). Labels for www.example.com are com, example and www.

This is an example of the domain with longest possible label (it leads to a scammy site): http://www.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk.com/. The domain name length = 71 characters.

This will be an example of longest domain name: abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcde.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk.abcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijk.com

Steve
  • 8,448
  • 23
  • 29
LazyOne
  • 4,889
  • 1
  • 26
  • 26
  • 1
    +1. It is also explained here: http://en.wikipedia.org/wiki/Hostname#Restrictions_on_valid_host_names – Ritesh Jul 17 '11 at 13:04
  • If you want an easy way to break many online systems out there, try signing up or using one of these with an email address @ one of the domains above. – Tim Fountain Jul 18 '11 at 17:56
  • 4
    Maybe you want to add a normative reference: RFC 1123, chapter 2.1 defines the 63 character limit. But where is the 253 limit defined? – Thomas Weller Apr 22 '16 at 06:54
  • RFC is RFC 1035, section 2.3.4, and it looks like it is 255 characters, not 253. – wp-overwatch.com Nov 04 '21 at 01:25
  • @wp-overwatch.com The 255 limit is in octets for the internal representation. The internal representation includes a byte for the length of each label, and a zero length that terminates the whole domain. So 255 = (1+63)+(1+63)+(1+63)+(1+63)+1. This equates to four 63-char segments plus three dots between them, which totals 253. The "longest domain name" in this answer reduces the first label from 63 to 57 to make room for the com label. – Ross Presser Feb 25 '22 at 17:09
  • Ross Presser comment above is correct and shows that the limit depends on the number of labels in fact, as each label adds one byte to encode the label length, so the more labels you have the less "actual" length you can have as more bytes are "consumed" to encode the length of labels. Also things become more complicated with IDNs, as they are encoded in ASCII with Punycode. But depending on which Unicode codepoints are used and the deltas between them, 63 bytes can correspond only to 20 or so codepoints, or maybe even less. – Patrick Mevzek Sep 29 '22 at 04:05
  • Is there any known actual website with a full 253 character domain name? – Brian Minton Jan 19 '23 at 17:24
10

It depends on what you want to do with the domain really.

For a domain just used as a website, the limit is 255 characters. Source: RFC2821 (April 2001) established this and RFC5321 (October 2008) retained this standard. To quote both of them...

4.5.3.1.2. Domain

The maximum total length of a domain name or number is 255 characters.

For a domain that works with emails, the limit is 253 characters. Source: See the requirements of local-parts (i.e., the user in user@example.com) from RFC821 (August 1982), page 29. This limit is imposed because the to field in e-mails cannot exceed 255 characters, one of those characters must be @, and the local-part must be at least one character long (i.e., a@(253-character-domain), which hits the SMTP 255 to-field limit).

HoldOffHunger
  • 231
  • 2
  • 7