# "Host is invalid" error when TLD is longer than 7 characters

**URL:** <https://meta.discourse.org/t/host-is-invalid-error-when-tld-is-longer-than-7-characters/46081>\
**Category:** Bug\
**Created:** [6월 20, 2016, 7:13오후 UTC](https://meta.discourse.org/t/host-is-invalid-error-when-tld-is-longer-than-7-characters/46081 "2016-06-20T19:13:23Z")\
**Posts on this page:** 1\
**Showing post:** 8

<div class="post-metadata">

**Author:** ![elijah](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/elijah/32/104055_2.png) [@elijah](https://meta.discourse.org/u/elijah)\
**Post date:** [7월 8, 2016, 12:14오전 UTC](https://meta.discourse.org/t/host-is-invalid-error-when-tld-is-longer-than-7-characters/46081/8 "2016-07-08T00:14:02Z")

</div>

> [@flimm](#):
>
> There you go. I changed 7 to 70. I release my changes under the CC0 license by Creative Commons and under the public domain.

It does not pass the Armenian localized domain in the first post:

.xn–y9a3aq

I cannot find any active domains in that TLD however for iframely test. ICANN names a [Persian TLD and site: http://نمونہ.آزمایشی (http://xn–hhbbbh02d.xn–hgbk6aj7f53bba)](https://www.icann.org/news/blog/idn-wiki-adding-urdu-and-thai) which also does not appear to have actually be in use, but gives a more extreme example, and one presumably that should be supported.

My, from memory, understanding of the rules of DNS labels are:

All labels are 1 to 63 characters, case insensitive A to Z, 0 to 9 and - (hyphen), all from ASCII.  
No labels may start with a hyphen.  
No top level domain label may start with a number.

That means a regexp for a valid domain name would look like:

`/^([a-z0-9][a-z0-9-]{0,62}\.)+[a-z][a-z0-9-]{0,62}\.?$/`

Domains that are _just_ a TLD are sufficiently bizarre as to be worth ignoring.

---

_[View the full topic](https://meta.discourse.org/t/host-is-invalid-error-when-tld-is-longer-than-7-characters/46081)._
