Qaynaq LABS · TOOLS

HTTP · 4xx Client Error

413 Payload Too Large

Server refuses to process request because payload exceeds server limits.

When you see this status

  • Uploading a file larger than server's max payload size
  • Sending a request body exceeding configured limits
  • POST/PUT request with body size beyond server threshold

Common causes

  • Misconfigured server payload size limits
  • Client sending unexpectedly large request body
  • Network proxy or gateway enforcing size restrictions

How to debug it

  1. Check server configuration for max payload size
  2. Verify client request body size
  3. Inspect proxy/gateway size limits
  4. Split large payloads into smaller chunks
  5. Increase server's configured payload limit

Return this code in your framework

Express (Node.js)
app.post('/upload', (req, res) => { if (req.get('Content-Length') > 1048576) return res.status(413).send('Payload too large'); });
FastAPI (Python)
from fastapi import FastAPI, HTTPException; app = FastAPI(); @app.post('/upload'); async def upload(): raise HTTPException(status_code=413, detail='Payload too large')
NestJS
@Post('/upload') upload(@Body() data: any) { if (data.size > 1048576) throw new PayloadTooLargeException(); }
Go (net/http)
func handler(w http.ResponseWriter, r *http.Request) { if r.ContentLength > 1048576 { http.Error(w, "Payload too large", 413); return } }

About HTTP 413

HTTP status code 413 Payload Too Large is part of the 4xx Client Error family. Server refuses to process request because payload exceeds server limits. Understanding it is essential for backend engineers, API designers, and anyone debugging integrations between services.

The Qaynaq Labs HTTP Status Code Explainer covers all standard codes with practical guidance: what triggers them, how to debug them in production, and exactly how to return them from common frameworks. Each code page is hand-curated and verified.

Frequently asked

Can I increase the server's payload limit?

Yes. Configure server-specific settings like client_max_body_size in Nginx or max_body_size in Express. Restart required.

How do I handle large file uploads?

Use chunked uploads, multipart uploads, or streaming. Implement resumable uploads for reliability.

Does 413 apply to GET requests?

No. GET requests typically don't have a body, so 413 is irrelevant. Only applies to requests with payloads.