414 URI Too Long: causes, server limits and how to fix it

A 414 means the request URL is longer than the server will accept. Why it happens, the default limits in nginx and Apache, and how to fix it by moving data to a POST body.

· 5 min read · By the Spot Downtime team

414 URI Too Long means the server refused a request because the URL in it was longer than the server is willing to process. The server is healthy. It is rejecting one specific request line.

You rarely hit this by typing a long address. It almost always comes from code that stuffs a lot of data into a query string, or from a bug that makes a URL grow on every request.

Common causes

  • Large data sent with GET. A search form, filter panel or API client puts hundreds of IDs or a long JSON blob into query parameters.
  • A redirect that appends to the URL. Each hop adds a parameter such as ?redirect= containing the previous URL, so the address doubles in size until the server gives up. This often ends in a too many redirects error or a 414.
  • Tracking or session state in the URL. Some frameworks and marketing tools append state to every link and never clean it up.
  • A client-side loop. JavaScript that rewrites location.search and reloads can grow the query string on each load.
  • A low limit somewhere in the path. The web server, a reverse proxy, a CDN or a load balancer can each enforce its own cap, and the smallest one wins.

What the limit actually is

The HTTP spec sets no maximum URL length. It only says servers should be prepared to handle the URLs they generate and may answer 414 when a URL is too long. Each piece of software picks its own cap:

  • nginx reads the request line into one header buffer. The default is large_client_header_buffers 4 8k, so a request line longer than 8 KB returns 414.
  • Apache uses LimitRequestLine, which defaults to 8190 bytes.
  • CDNs, load balancers and proxies have their own limits, documented by each provider. They are often lower than your origin's.
  • Browsers accept very long URLs, but older clients and many tools do not. A common rule of thumb is to keep URLs under about 2,000 characters if you want them to work everywhere.

Find out where the 414 comes from

First reproduce it and see which server answers. The Server header and the body of the error page usually name the component:

curl -sI "https://example.com/search?q=$(python3 -c 'print("a"*10000)')" | head -n 5

If the response comes from your CDN or load balancer, its limit is the one to raise or work around. If it comes from nginx or Apache, check the logs. nginx logs the failed request in the error log as client sent too long URI while reading client request line. Compare the failing URL length against the limits above:

# length of the URL that failed
printf '%s' "$URL" | wc -c

Then ask why the URL is that long. Look at the URL itself. A repeating pattern means a loop or redirect bug. A long list of IDs means data that belongs in a body.

Fix it

1. Send the data in a POST body

This is the real fix when the URL is long because of the payload. Move the parameters from the query string to the request body:

# before: breaks once the list gets long
curl "https://api.example.com/items?ids=1,2,3,...,5000"

# after
curl -X POST https://api.example.com/items/search \
  -H "Content-Type: application/json" \
  -d '{"ids":[1,2,3,5000]}'

Searching with POST is a common, accepted pattern when the query is too big for a URL. If the operation is read-only, document it that way so caches and clients do not assume it changes data.

2. Stop the URL from growing

If you see the same parameter repeated or nested, trace the redirect or script that adds it. Redirects should replace parameters, not wrap the previous URL inside a new one. Strip tracking parameters once they have been read.

3. Raise the server limit (only if you must)

A larger limit makes sense when URLs are long for a legitimate reason and you cannot change the client. nginx, in the http or server block:

large_client_header_buffers 4 16k;

Apache, in the server or virtual host config:

LimitRequestLine 16384

Reload the server, then retest:

sudo nginx -t && sudo systemctl reload nginx
# or
sudo apachectl configtest && sudo systemctl reload apache2

Raise limits with care

The caps exist partly to blunt abuse. Raising them also raises memory use per connection. And if a CDN or load balancer sits in front, raising only the origin changes nothing, because the request is rejected before it gets there.

414 or 431?

The two look similar but are different limits. 414 is about the request line, meaning the method, URL and protocol version. 431 Request Header Fields Too Large is about the headers, often a bloated cookie. In nginx both share the same buffer setting, which is why raising it can fix either one.

Catch it before users do

A 414 only affects requests with long URLs, so a homepage check will never see it. If you have an endpoint that takes many parameters, such as search or export, monitor a representative request with realistic parameters. Spot Downtime's API monitoring lets you send custom requests and alerts you when a check stops getting a successful response.

  1. Reproduce with the exact URL and measure its length.
  2. Identify which layer (CDN, proxy, web server) returned the 414.
  3. Move large data to a POST body or fix the loop that grows the URL.
  4. Raise the limit at that layer only if you cannot change the client.
Bulk HTTP status checkerTest a batch of URLs and see which ones return 414 or another error.

Get new guides by email

Practical posts on monitoring, outages, error fixes and on-call, when they're published. No spam.

Unsubscribe from any email with one click. See our privacy policy.

Keep reading