HTTP Status Codes

413 413 Payload Too Large

The request body exceeds the server's maximum allowed size.

What Is This?

The HTTP 413 Payload Too Large status code (formerly known as 413 Request Entity Too Large) indicates that the request body exceeds the server's maximum allowed size. Every server has limits on how large a request body it will accept. This limit protects the server from resource exhaustion attacks and accidental oversized uploads.

Common Causes & Solutions

1

Common Cause

File upload exceeding the server's maximum body size

2

Common Cause

JSON or form data payload larger than the configured limit

3

Common Cause

Base64-encoded data that expands significantly in size

4

Increase the upload limit

Configure your web server and application framework to allow larger request bodies.

# Nginx (increase to 50MB)
client_max_body_size 50M;

# Express.js
app.use(express.json({ limit: '50mb' }))
app.use(express.urlencoded({ limit: '50mb', extended: true }))

# Apache
LimitRequestBody 52428800

# Vercel/Next.js API route
// Vercel has a 4.5MB body limit for serverless functions
// For larger uploads, use client-side upload to blob storage
5

Implement chunked uploads

For large files, implement chunked uploads that split the file into smaller pieces sent sequentially.

// Client-side chunked upload
const CHUNK_SIZE = 1024 * 1024 // 1MB
async function uploadChunked(file) {
  for (let i = 0; i < file.size; i += CHUNK_SIZE) {
    const chunk = file.slice(i, i + CHUNK_SIZE)
    await fetch('/api/upload', {
      method: 'POST',
      headers: {
        'Content-Range': `bytes ${i}-${i + chunk.size - 1}/${file.size}`,
        'Content-Type': 'application/octet-stream'
      },
      body: chunk
    })
  }
}

Related Entries

More from this reference:

Frequently Asked Questions

What is a reasonable maximum body size?

For most APIs, 1-10 MB is reasonable. For file upload APIs, 10-100 MB is common. For video or large media files, use chunked uploads or direct-to-cloud-storage uploads instead of increasing the limit significantly.

Does 413 apply to URL length too?

URL length limits are separate and typically return 414 URI Too Long. The 413 status specifically applies to the request body size, not the URL or headers.