quarkusio/quarkus · error · IOException

Request too large

Error message

Request too large

What it means

The request body exceeded quarkus.http.limits.max-body-size while the response headers were already written, so Quarkus cannot send a 413 status; it aborts by closing the underlying connection and throws IOException("Request too large").

Source

Thrown at extensions/vertx-http/runtime/src/main/java/io/quarkus/vertx/http/runtime/VertxInputStream.java:91

        return read(b, 0, b.length);
    }

    @Override
    public int read(final byte[] b, final int off, final int len) throws IOException {
        if (closed) {
            throw new IOException("Stream is closed");
        }
        if (continueState == ContinueState.REQUIRED) {
            continueState = ContinueState.SENT;
            exchange.request.response().writeContinue();
        }
        readIntoBuffer();
        if (limit > 0 && exchange.request.bytesRead() > limit) {
            HttpServerResponse response = exchange.request.response();
            if (response.headWritten()) {
                //the response has been written, not much we can do
                exchange.request.connection().close();
                throw new IOException("Request too large");
            } else {
                response.setStatusCode(HttpResponseStatus.REQUEST_ENTITY_TOO_LARGE.code());
                response.headers().add(HttpHeaderNames.CONNECTION, "close");
                response.endHandler(new Handler<Void>() {
                    @Override
                    public void handle(Void event) {
                        exchange.request.connection().close();
                    }
                });
                response.end();
                throw new IOException("Request too large");
            }
        }
        if (finished) {
            return -1;
        }
        if (len == 0) {
            return 0;

View on GitHub (pinned to e1c734241f)

Solutions

  1. Increase quarkus.http.limits.max-body-size (e.g. quarkus.http.limits.max-body-size=50M) to accommodate legitimate payloads.
  2. Compress or chunk client uploads so each request stays under the limit.
  3. Read/validate the request body BEFORE writing any response bytes, so the server can still answer with HTTP 413 instead of a hard connection close.
  4. If a reverse proxy fronts Quarkus, align its body-size limits (e.g. nginx client_max_body_size) with quarkus.http.limits.max-body-size.

Example fix

// before (application.properties)
# quarkus.http.limits.max-body-size not set (default 10M)
// after
quarkus.http.limits.max-body-size=100M
Defensive patterns

Strategy: validation

Validate before calling

long max = Long.getLong("quarkus.http.limits.max-body-size.bytes", 10L*1024*1024);
if (request.getContentLengthLong() > max) {
    response.sendError(413); return;
}

Try / catch

try {
    in.read(buf);
} catch (IOException e) {
    if ("Request too large".equals(e.getMessage())) {
        response.setStatusCode(413); /* and stop processing */
    } else throw e;
}

Prevention

When it happens

Trigger: Client uploads a body larger than quarkus.http.limits.max-body-size and the application starts reading it only after the response head has been committed (e.g. streaming a partial response before draining the input).

Common situations: Large file uploads exceeding the default 10240K limit; limits lowered for an endpoint but another filter/proxy already began the response; streaming download of error details while upload continues.

Related errors


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/23452f9fb32c2434. Report an issue: GitHub.