---
title: "Risolvi l’errore 413 Request Entity Too Large e scopri quale livello ha rifiutato il body"
description: "HTTP 413 Content Too Large, in nginx Request Entity Too Large, significa che un server ha rifiutato il body di una richiesta perché troppo grande. Il Content-Type mostra quale livello l’ha inviato."
canonical: "https://logbrew.co/it/errors/http-413"
last_updated: "2026-11-24"
---

# Risolvi l’errore 413 Request Entity Too Large e scopri quale livello ha rifiutato il body

HTTP 413 Content Too Large, in nginx Request Entity Too Large, significa che un server ha rifiutato il body di una richiesta perché troppo grande. Il `Content-Type` mostra quale livello l’ha inviato.

Alza `client_max_body_size` se il 413 è la pagina HTML di nginx, e invia richieste più piccole se è JSON della tua app.

Testato il 24 novembre 2026 con nginx 1.31.8, curl 8.7.1, jq 1.7.1 e logbrew CLI 0.1.96

Di [Furkan Erday](https://github.com/furkanerday). Furkan Erday è il fondatore di LogBrew. Sviluppa LogBrew ogni giorno con Claude Code e Codex.

Canonical: https://logbrew.co/it/errors/http-413

## Quale livello ha accettato ogni body

| Body inviato | nginx l’ha passato | L’API l’ha accettato |
| --- | --- | --- |
| 2.166.027 byte, nginx a `1m` | No, `413` | No |
| 2.166.027 byte, nginx a `8m` | Sì | `200` |
| 5.124.027 byte | Sì | No, `413` |
| 59.602 byte in gzip | Sì | No, `413` |
| 5.124.027 byte in 2 metà | Sì | `200` per entrambe |

5 batch di log OTLP attraverso nginx 1.31.8 verso un’API locale di LogBrew, inviati con curl 8.7.1.

## Scopri quale livello ha rifiutato il body

### Leggi il Content-Type del 413

nginx risponde con una sua pagina HTML, `Content-Type: text/html`, e il suo nome in fondo. Con `client_max_body_size 1m`, il nostro batch da 2.166.027 byte ha ricevuto questa pagina.

```bash
curl -sS -i http://127.0.0.1:28413/v1/logs \
  -H "x-logbrew-key: $LOGBREW_INGEST_KEY" -H 'Content-Type: application/json' \
  --data-binary @batch-2mb.json
```

Output

```text
HTTP/1.1 413 Request Entity Too Large
Server: nginx/1.31.8
Date: Tue, 24 Nov 2026 01:17:12 GMT
Content-Type: text/html
Content-Length: 183
Connection: close

<html>
<head><title>413 Request Entity Too Large</title></head>
<body>
<center><h1>413 Request Entity Too Large</h1></center>
<hr><center>nginx/1.31.8</center>
</body>
</html>
```

### Cerca un 100 Continue prima del 413

nginx ha rifiutato il nostro body in base al `Content-Length` e non ha inviato `100 Continue`. Quando nginx ha lasciato passare un body da 5.124.027 byte, curl ha mostrato prima `100 Continue` e poi il 413 dell’app in JSON. Entrambe le risposte avevano `Server: nginx/1.31.8`, perché nginx mette questo header anche sulle risposte dell’app.

Output

```text
HTTP/1.1 100 Continue

HTTP/1.1 413 Payload Too Large
Server: nginx/1.31.8
Date: Tue, 24 Nov 2026 01:21:54 GMT
Content-Type: application/json
Content-Length: 82
Connection: keep-alive

{"message":"request body is over 4 MiB after decompression; send smaller batches"}
```

### Trova la riga nel log degli errori di nginx

Quando nginx rifiuta un body, scrive 1 riga al livello predefinito `error`, con la dimensione che il client voleva inviare. Il 413 dell’app non aggiunge nulla al log degli errori di nginx.

Output

```text
2026/11/24 04:17:12 [error] 28243#0: *6 client intended to send too large body: 2166027 bytes, client: 127.0.0.1, server: , request: "POST /v1/logs HTTP/1.1", host: "127.0.0.1:28413"
```

### Registra upstream_status accanto allo stato

Aggiungi `$content_length` e `$upstream_status` a un `log_format` nel blocco `http`. `upstream_status` vale `-` quando nginx ha rifiutato il body da solo, e `413` quando l’ha rifiutato l’app.

```bash
log_format body '$remote_addr "$request" $status '
                'content_length=$content_length upstream_status=$upstream_status';
access_log /var/log/nginx/body.log body;
```

Output

```text
127.0.0.1 "POST /v1/logs HTTP/1.1" 413 content_length=2166027 upstream_status=-
127.0.0.1 "POST /v1/logs HTTP/1.1" 413 content_length=5124027 upstream_status=413
```

## Risolvi

### Alza client_max_body_size in nginx

Il valore predefinito è `1m`. Imposta un valore più alto nel blocco `http`, `server` o `location` che riceve l’upload, poi esegui `nginx -s reload`. Con `8m`, nginx ha passato lo stesso batch da 2.166.027 byte all’API, e l’API ha risposto `200`.

```bash
client_max_body_size 8m;
```

Output

```text
127.0.0.1 "POST /v1/logs HTTP/1.1" 200 content_length=2166027 upstream_status=200
```

### Resta sotto il limite dell’app

nginx non cambia il limite dell’app che ha dietro. L’API di LogBrew legge al massimo 4 MiB su `/v1/logs` e 2 MiB su `/v1/events`, e il suo 413 dice quale. Gzip non lo aggira. Un body gzip da 59.602 byte che si decomprimeva in 5.124.027 byte ha ricevuto anch’esso un 413.

Output

```text
{"code":"payload_too_large","error":"request body is over 2097152 bytes","limit_bytes":2097152,"next":"send under limit_bytes per request; split a batch into smaller requests","next_action":{"code":"split_batch","target":"request"}}
```

### Dividi invece il batch

Un limite più alto sposta solo il 413 sul prossimo batch grande. Abbiamo diviso il batch da 5.124.027 byte e 13.000 log, ottenendo 2 batch da 6.500, e l’API li ha accettati entrambi. Gli SDK JavaScript e Python di LogBrew lo fanno per te. Ogni richiesta contiene al massimo 100 eventi e 256 KiB.

Output

```text
batch-5mb.json 413
batch-5mb-part1.json 200
batch-5mb-part2.json 200
```

### Invia le righe 413 a LogBrew

LogBrew non ha un’integrazione con nginx, ma accetta log OTLP. Questo comando invia ogni riga 413 dell’access log e ogni riga `too large body` del log degli errori come 1 log. Imposta `LOGBREW_INGEST_KEY` su una chiave `server` del tuo progetto. La nostra API locale di LogBrew ha risposto `{}`, quindi ha accettato ogni riga.

```bash
{ grep -E '" 413 ' /var/log/nginx/body.log; grep 'too large body' /var/log/nginx/error.log; } |
  jq -Rn '{resourceLogs: [{resource: {attributes: [{key: "service.name", value: {stringValue: "nginx"}}]}, scopeLogs: [{logRecords: [inputs | {severityText: (if test("\\[error\\]") then "ERROR" else "WARN" end), body: {stringValue: .}}]}]}]}' |
  curl -sS https://api.logbrew.co/v1/logs -H "x-logbrew-key: $LOGBREW_INGEST_KEY" \
    -H 'Content-Type: application/json' --data-binary @-
```

Output

```text
{}
```

### Trovale con la CLI di LogBrew

La riga del log degli errori riceve il livello `error`, e ogni riga 413 riceve `warning`. Cerca `upstream_status=-` per vedere solo i body rifiutati da nginx.

```bash
logbrew read logs --project "<project_id>" --service nginx --severity error --since 1h
logbrew read logs --project "<project_id>" --service nginx --search 'upstream_status=-' --since 1h
```

Output

```text
Logs (1)
- error 2026/11/24 04:17:12 [error] 28243#0: *6 client intended to send too large body: 2166027 bytes, client: 127.0.0.1, server: , request: "POST /v1/logs HTTP/1.1", host: "127.0.0.1:28413" service=nginx trace=ec27d913a85bdbfe8252a31cf276fccf [unversioned / production]
Logs (1)
- warning 127.0.0.1 "POST /v1/logs HTTP/1.1" 413 content_length=2166027 upstream_status=- service=nginx trace=b2f9eee905fea8254bac86a398fd8f39 [unversioned / production]
```

## Cosa abbiamo visto nel test

Abbiamo eseguito nginx 1.31.8 su macOS 27.2 a `127.0.0.1:28413`, davanti a un’API locale di LogBrew. curl 8.7.1 ha inviato 5 batch di log OTLP a `/v1/logs` con `--data-binary`.

Con `client_max_body_size 1m`, nginx ha rifiutato il batch da 2.166.027 byte e l’API non l’ha mai visto. Con `8m`, l’API ha rifiutato ogni batch oltre 4 MiB, anche quello in gzip, e ha accettato le 2 metà.

|  | `$status` | `$upstream_status` |
| --- | --- | --- |
| 2.166.027 byte, nginx a `1m` | `413` | `-` |
| 2.166.027 byte, nginx a `8m` | `200` | `200` |
| 5.124.027 byte | `413` | `413` |
| 59.602 byte in gzip | `413` | `413` |
| 5.124.027 byte in 2 metà | `200` | `200` |

## Perché il 413 ha 3 nomi

La sezione 15.5.14 della RFC 9110 chiama il 413 `Content Too Large`. La RFC 7231 lo chiamava `Payload Too Large` e la RFC 2616 `Request Entity Too Large`. nginx 1.31.8 invia ancora il nome più vecchio e l’API di LogBrew invia `Payload Too Large`, quindi il nome non dice chi l’ha inviato.

La documentazione di nginx su `ngx_http_core_module` dà a `client_max_body_size` il valore predefinito `1m`, e `0` disattiva il controllo. nginx ha confrontato il limite con il `Content-Length` prima di leggere il nostro body, quindi l’app non ha mai visto la richiesta rifiutata.

1. Il client invia `Content-Length`
2. nginx controlla `client_max_body_size`
3. L’app legge il body fino al proprio limite

## Cosa registra LogBrew

LogBrew ha salvato ogni riga inviata come 1 log del servizio `nginx`. Tiene l’intera riga come messaggio e non la divide in campi, quindi cerca nel testo.

La dashboard, la CLI e il server MCP leggono questi log come qualsiasi altro log di LogBrew.

- `nginx`
  - `level`: `error`
  - Messaggio: `… client intended to send too large body: 2166027 bytes …`
  - `trace`: `ec27d913a85bdbfe8252a31cf276fccf`

## Domande frequenti

### Cosa significa 413 Content Too Large?

Il server ha rifiutato la richiesta perché il suo body è più grande di quanto accetta. La RFC 9110 chiama lo stato 413 `Content Too Large`.

### Che differenza c’è tra 413 Request Entity Too Large e 413 Payload Too Large?

Nessuna. Sono 2 nomi vecchi dello stesso stato. nginx invia `Request Entity Too Large`, e molte app inviano `Payload Too Large`.

### Come risolvo 413 Request Entity Too Large in nginx?

Alza `client_max_body_size` nel blocco che riceve la richiesta, per esempio a `8m`, poi esegui `nginx -s reload`. Il valore predefinito è `1m`.

### Perché ricevo ancora 413 dopo aver alzato client_max_body_size?

La tua app ha un suo limite. Se il 413 è JSON e non la pagina HTML di nginx, il body l’ha rifiutato l’app. Invia richieste più piccole o alza il limite dell’app.

### Gzip risolve l’errore 413?

No, se l’app conta i byte dopo la decompressione. Il nostro body gzip da 59.602 byte ha passato nginx, ma l’API di LogBrew l’ha decompresso in 5.124.027 byte e ha inviato un 413.

## Cerca ogni riga 413 in 1 solo posto

Invia le righe di log di nginx a LogBrew come log OTLP e cercale dalla dashboard, dalla CLI o dal tuo agente IA. Inizia con il generoso piano gratuito, senza carta.

[Inizia gratis](https://logbrew.co/it)

## Fonti

- [RFC 9110, HTTP Semantics, 15.5.14 413 Content Too Large](https://www.rfc-editor.org/rfc/rfc9110#section-15.5.14)
- [LogBrew docs, Send OpenTelemetry data to LogBrew with OTLP](https://docs.logbrew.co/guides/opentelemetry)
- [LogBrewCo/sdk, JavaScript SDK, Queue Bounds](https://github.com/LogBrewCo/sdk/blob/main/js/logbrew-js/README.md#queue-bounds)

## Altre soluzioni agli errori

- [Risolvi l’errore di script che nasconde messaggio, file e riga](https://logbrew.co/it/errors/script-error)
- [Risolvi l’errore Failed to fetch e distingui le sue 3 cause](https://logbrew.co/it/errors/failed-to-fetch)
- [Risolvi java.lang.NullPointerException in Kotlin e Android partendo dal messaggio](https://logbrew.co/it/errors/nullpointerexception)
- [Risolvi l’errore Minified React #418 e #185 con il messaggio completo e la tua riga di codice](https://logbrew.co/it/errors/minified-react-error)
- [Risolvi Cannot use import statement outside a module nel browser e in Node.js](https://logbrew.co/it/errors/cannot-use-import-statement-outside-a-module)
- [Risolvi l’errore di rete AxiosError e scopri quale delle 3 cause hai](https://logbrew.co/it/errors/axios-network-error)
- [Risolvi l’errore HTTP 499 e scopri chi ha smesso di aspettare](https://logbrew.co/it/errors/http-499)
- [Errori che abbiamo riprodotto, e come risolvere ciascuno](https://logbrew.co/it/errors)
