413

개요

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' }));

흔한 원인

해결 방법

실무 참고

관련 상태코드

관련 헤더

스펙 근거