413 Content Too Large(옛 이름 Payload Too Large)는 요청 본문이 서버가 처리하도록 허용한 크기 한도를 넘어섰다는 뜻입니다. 파일 업로드, 대용량 JSON, base64 인코딩된 데이터 전송에서 흔히 만납니다.
한도는 애플리케이션(Express body-parser limit 등)뿐 아니라 그 앞단의 리버스 프록시(Nginx client_max_body_size, 클라우드 LB, API 게이트웨이)에서도 걸릴 수 있으므로, 어느 계층이 거부했는지부터 확인해야 합니다.
POST /uploads HTTP/1.1
Host: api.example.com
Content-Type: image/png
Content-Length: 47185920
<47 MB body>HTTP/1.1 413 Content Too Large
Content-Type: application/json
{"error":"file_too_large","maxBytes":10485760}# Default is 1m; raise it where large uploads are expected
http {
client_max_body_size 20m;
}const express = require('express');
const app = express();
// Reject bodies over 10 MB with a 413
app.use(express.json({ limit: '10mb' }));