Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

HTTP 414 error: the web server says the URL is too long

Error414 Request-URI Too Large

Short answer

A 414 means the server refused the request because the URL is longer than it accepts. Most often a form or script sends large data in a GET query string. Send it in a POST body instead. If the URL grows on every request, you have a redirect loop. Raise server limits last.

  • Applies to nginx 1.26, Apache 2.4, PHP 8.3
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Measure the URL that fails. Copy it from the browser or the access log and count its characters.

    printf '%s' 'PASTE-THE-FAILING-URL-HERE' | wc -c
  2. 2Match what you see, then jump to its fix

    1. 1The URL has a very long query string, for example a filter list, IDs, or form fields, and it is a GET request.Large data is sent in the query string of a GET requestFix
    2. 2The 414 appears after several redirects, and the address in the browser grows each time (a prefix or parameter is added on every hop).A redirect loop keeps making the URL longerFix
    3. 3The response comes from nginx and the URL is long but legitimate (for example a long signed link).nginx request line is larger than one header bufferFix
    4. 4The response comes from Apache and the request line is longer than 8190 bytes, or LimitRequestLine was lowered in your config.Apache LimitRequestLine is lower than the URL lengthFix

What does the error look like?

  • 414 Request-URI Too Large

Cause 1 of 4

Large data is sent in the query string of a GET request

1Check

RFC 9110 names a POST improperly converted to a GET with long query information as a usual cause of 414. Check the form method or the HTTP call.

grep -rn "method=\"get\"\|method='get'" templates/ public/

2Fix

Send the data in the request body with POST, and keep only short identifiers in the URL.

<form method="post" action="/search">
  <input type="hidden" name="ids" value="1,2,3">
</form>

3Verify

Submit the form and check for a 200 instead of 414.

curl -s -o /dev/null -w "%{http_code}\n" -X POST -d "ids=1,2,3" https://example.com/search

Confirmed by rfc-editor.org

Did this fix it?

Cause 2 of 4

A redirect loop keeps making the URL longer

1Check

RFC 9110 lists a client stuck in an infinite loop of redirection, where a redirected URI prefix points to a suffix of itself, as another cause. Follow the redirects and watch the Location header.

curl -sIL --max-redirs 10 https://example.com/start | grep -i "^location"

2Fix

Fix the rewrite or redirect rule that appends to the URL instead of replacing it, so the same request ends after one redirect.

# nginx: a redirect that does not repeat itself
location = /old-page {
    return 301 /new-page;
}

3Verify

Run the redirect check again; it should show one hop.

curl -sIL --max-redirs 10 https://example.com/old-page | grep -i "^location"

Confirmed by rfc-editor.org

Did this fix it?

Cause 3 of 4

nginx request line is larger than one header buffer

1Check

nginx returns 414 when the request line does not fit in one buffer set by large_client_header_buffers. The default is 4 buffers of 8k.

sudo nginx -T 2>/dev/null | grep -n "large_client_header_buffers"

2Fix

Raise the buffer size in the http or server block. Keep it as small as you can, and prefer shortening the URL.

large_client_header_buffers 4 16k;

3Verify

Test the config, reload nginx and repeat the request.

sudo nginx -t && sudo systemctl reload nginx

Confirmed by nginx.org

Did this fix it?

Cause 4 of 4

Apache LimitRequestLine is lower than the URL length

1Check

LimitRequestLine sets the bytes allowed on the request line (method, URI and protocol), so it limits the URL including the query string. The default is 8190.

grep -rn "LimitRequestLine" /etc/apache2/ /etc/httpd/ 2>/dev/null

2Fix

Raise the value in server config or the virtual host. The manual advises against changing it without need, so do this only for a URL you cannot shorten.

LimitRequestLine 16380

3Verify

Check the syntax, reload Apache and repeat the request.

curl -s -o /dev/null -w "%{http_code}\n" "https://example.com/path?long=query"

Confirmed by httpd.apache.org

Did this fix it?

How do I stop it coming back?

  • Use POST for searches and filters that carry lists of values.
  • Log the longest request URLs once a month so growth is noticed early.
  • Keep links you send in email short; avoid putting full state in the URL.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Projects of mine built on the same technologies:

Related fixes

Servers

nginx gives up waiting for the app and returns 504

upstream timed out (110: Connection timed out) while reading response header from upstream

nginx returns 504 when the app behind it takes the request but sends nothing back within proxy_read_timeout (60 seconds by default), or when the connection cannot be opened in time.

5 causes, each with a fix

Servers

Cookies from a PHP backend vanish behind an nginx proxy

Login works when you call the backend directly but fails through nginx

nginx forwards Set-Cookie headers from the backend unchanged, so lost cookies usually come from the cookie itself: a domain or path that does not match the public URL, or Secure and SameSite flags the browser rejects.

4 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.