HTTP 414 URI Too Long: what it means and how to fix it
Meaning
HTTP 414 URI Too Long means the request target exceeds a server or proxy limit. Shorten the query or move state into a request body.
HTTP 414 means the request target is longer than the server is willing to parse. RFC 9110 section 15.5.15 calls the reason phrase “URI Too Long” and says the server is refusing because the target URI is longer than it will interpret. The target includes the path and query string. It does not include the request headers or the response body.
Long query strings are the usual cause. A crawler can build one by appending every filter, tracking parameter and cursor to a URL. A browser can create the same failure when a form serialises a large state object into the query string. A proxy may reject the absolute-form URL before the request reaches the origin, or it may relay the origin’s 414. Read the response headers before changing the exit address.
Reproduce it with curl
This standard-library server is Python 3.15.0. It answers short GET requests, but the parser returns 414 when the request target crosses its limit. The test used curl 8.23.0 and a 70,000-character path:
# plain.py
from http.server import BaseHTTPRequestHandler, HTTPServer
class H(BaseHTTPRequestHandler):
def do_GET(self):
self.send_response(200)
self.send_header("Content-Length", "3")
self.end_headers()
self.wfile.write(b"ok\n")
def log_message(self, *args):
pass
HTTPServer(("127.0.0.1", 8414), H).serve_forever()
$ curl -si "http://127.0.0.1:8414/$(python3 -c 'print("a"*70000)')"
HTTP/1.0 414 URI Too Long
Server: BaseHTTP Python/3.15.0
Connection: close
Content-Type: text/html;charset=utf-8
Content-Length: 444
<p>Error code: 414</p>
<p>Message: URI Too Long.</p>
The saved capture is from the local server and curl 8.23.0. A raw-socket bisection against the same Python process accepted a path of 65,521 bytes and refused the next byte with 414. That boundary is an implementation detail, not a protocol limit. The request line, headers and parser settings all affect it.
What changes when a proxy is in the path
Forward proxies receive an absolute-form target such as GET http://example.test/path?... HTTP/1.1. That adds the scheme and host to what the proxy must parse. In the local test, Squid 6.13 refused a long absolute target with 400 Bad Request and X-Squid-Error: ERR_INVALID_URL, while the origin’s Python parser returned 414. A 400 with that Squid diagnostic is the proxy’s limit, not evidence that the site removed the URL.
HTTPS through CONNECT is different. The proxy sees only CONNECT host:443; the long path is inside the encrypted tunnel and the origin or its reverse proxy decides whether it is too long. A proxy can still answer 502 or 504 if the tunnel fails, so compare a direct request with the proxied one and record Server and Via headers.
Causes and fixes
| Cause | How to confirm it | What to change |
|---|---|---|
| Query string grew with filters or cursors | curl -v shows a very long request line; a shorter query returns 200 |
Send the filters in a POST body, paginate with a short cursor, or remove duplicate parameters |
| Redirect loop appends a parameter each time | curl -IL shows the Location value growing on every hop |
Fix the redirect builder and limit redirects while diagnosing |
| Proxy parser rejects absolute-form URLs | The response names Squid or another forward proxy and includes its parser error | Shorten the target, upgrade or reconfigure the proxy you operate, and keep the origin URL inside CONNECT for HTTPS |
| Path routing is being used as a data store | Only URLs with an encoded JSON or filter blob fail | Use a server-side record keyed by a short ID and expire it deliberately |
| Host and path were concatenated twice | The request line contains two schemes or a repeated path prefix | Build the URL once and log the final request target before sending |
For a scraper, retrying unchanged wastes a request. First fetch the same resource with the query reduced to one filter, then compare the direct and proxied response. A new proxy exit only helps if the refusal came from a per-proxy parser limit. If the origin owns the limit, keep the same session and change the request shape. The curl proxy guide shows how to preserve the URL’s hostname while pinning an address, and HTTP CONNECT explains why HTTPS hides the path from a forward proxy.