kannappan
kannappan

Reputation: 289

Request Line is too large - Gunicorn

I have been using Flask for over a year, I used deploy my Flask app into production using Gunicorn WSGI server. Recently I encountered a weird error that,

<html>
  <head>
    <title>Bad Request</title>
  </head>
  <body>
    <h1><p>Bad Request</p></h1>
    Request Line is too large (4269 &gt; 4094)
  </body>
</html>

I encountered this error for most of my GET requests.

While debugging I came to know that, I need to increase the --limit-request-line config in Gunicorn after I increased that to 8190 in my Dockerfile, I was able to see the responses from the Flask app successfully.

The dockerfile change I made was

CMD gunicorn app:app  -w 2 --threads 50 -b 0.0.0.0:8080 --limit-request-line 8190 --capture-output --log-level info

My question here is, Why did the http request line size/length increase suddenly, because I haven't redeployed my Flask app in past 40 days, so the Gunicorn version wasn't changed. The server was returning responses perfectly for 39 days, then suddenly it gave me this error.

Any idea on this?

Edit1: I found that the issue was due to the large get request being formed due to multiple filter values.

Upvotes: 1

Views: 2422

Answers (1)

IJN
IJN

Reputation: 11

Set --limit-request-line to 0. This will allow unlimited request length. However, add a request size validation inside code to avoid any security risks.

Upvotes: 0

Related Questions