How Long Can a URL Be? The Limits at Each Layer

There is no single maximum length for a URL. The standards set limits on some parts and recommendations for the rest. The hostname can be at most 253 characters, with 63 per label, under the DNS rules. For the whole URL, the HTTP specification, RFC 9110, recommends that all senders and recipients support URIs of at least 8,000 octets, but does not set an upper limit. In practice the limit you meet is set by software: web servers, proxies and content delivery networks have configurable caps on request-line or header size, browsers have their own limits, and some formats set firm rules, such as the 2,048-character limit for URLs in XML sitemaps. Keeping URLs well under 2,000 characters avoids almost all of these.

The limits, layer by layer

LayerLimitSource or where it is set
Each hostname label63 octetsRFC 1035
Full hostname253 characters as written (255 octets on the wire)RFC 1035
URI syntaxNo maximum definedRFC 3986
HTTPSupport at least 8,000 octets recommendedRFC 9110
Web servers and proxiesConfigurable request-line or header buffer limitsServer configuration; defaults vary by product and version
BrowsersImplementation limits, usually far above everyday URLsEach browser's own behaviour
XML sitemapsFewer than 2,048 characters per URLThe sitemaps.org protocol

The hostname rows are the same limits listed in our reference table of domain numbers, and the reasons for 63 and 253 are set out in why the label limit is 63.

Why the standards avoid a hard maximum

RFC 3986 defines what a URI may contain, not how long it may be, because different schemes and systems have different needs. HTTP's newer specification takes a practical position instead: it recommends that implementations support at least 8,000 octets, so that ordinary URLs, even long ones with tracking or search parameters, work everywhere. A server that receives a request target longer than it is willing to handle should respond with status 414, URI Too Long, which RFC 9110 also defines.

Where long URLs actually break

A note on fragments and query strings

Not every part of a URL travels to the server. The fragment, the part after #, stays in the browser and is never sent in the HTTP request, so it does not count against server limits, although it still counts for anything that stores or displays the full link. The query string, after ?, does travel with the request and is usually where long URLs come from: search filters, encoded state and tracking parameters add up quickly. When a query string grows, that is often a sign the data belongs in a request body or in server-side state instead.

Counting a URL's length correctly

Lengths are counted after encoding. Characters outside the allowed set, such as spaces or non-ASCII letters in a path, are percent-encoded, so one character can become three, six or more octets on the wire. An internationalised hostname is converted to its ASCII A-label form, beginning xn--, which is usually longer than the Unicode form. Our encoded length arithmetic and walk-through from Unicode to xn-- show how to do the count. A URL that looks short in an address bar can be much longer when sent.

Practical guidance for site owners and developers

  1. Keep page URLs short and readable. Descriptive paths of a few words are easier to share and less likely to be cut off.
  2. Send large data in the request body. If a form or API call would put a lot of data in the query string, use POST with a body instead of GET.
  3. Watch tracking parameters. Stacked campaign parameters can make shared links surprisingly long.
  4. Check every layer you control. Server, proxy and CDN limits should all comfortably exceed your longest legitimate URL.
  5. Check hostname length early. If you generate hostnames automatically, validate them against the label and total limits before creating DNS records; see how to check a long hostname before creating it.

Capitalisation also matters for how URLs are matched; that is covered in which parts of a URL are case-sensitive.

Frequently asked questions

What is the maximum length of a URL?

No standard sets one. HTTP recommends supporting at least 8,000 octets, the hostname is limited to 253 characters, and real limits are set by servers, proxies, browsers and formats such as sitemaps.

Is 2,048 characters a URL limit?

It is the sitemaps.org limit for URLs listed in a sitemap, and a sensible upper target for shareable links, but it is not a limit in the HTTP or URI standards.

What error does a server return for a URL that is too long?

Status 414, URI Too Long, is defined for this case. Some software returns 400 Bad Request instead.

For more limits with their sources, return to the Learn hub.