Skip to content

Instantly share code, notes, and snippets.

@Maqsim
Last active May 21, 2024 12:23
Show Gist options
  • Save Maqsim/857a14a4909607be13d6810540d1b04f to your computer and use it in GitHub Desktop.
Save Maqsim/857a14a4909607be13d6810540d1b04f to your computer and use it in GitHub Desktop.
HOW TO FIX "413 Payload too large" in NodeJS (Express)
const express = require('express');
const bodyParser = require('body-parser');
...
// Express 4.0
app.use(bodyParser.json({ limit: '10mb' }));
app.use(bodyParser.urlencoded({ extended: true, limit: '10mb' }));
// Express 3.0
app.use(express.json({ limit: '10mb' }));
app.use(express.urlencoded({ limit: '10mb' }));
...
@Shahtaymur
Copy link

FYI: you have to put those lines before app.use(express.json());

this worked for me.. 👍

@Rahad23
Copy link

Rahad23 commented Mar 18, 2024

not work :(

error:

413: PAYLOAD_TOO_LARGE
Code: FUNCTION_PAYLOAD_TOO_LARGE

this my code :

app.use(bodyParser.json({ limit: '100mb' }));
app.use(bodyParser.urlencoded({ extended: true, limit: '100mb' }));
app.use(express.json());

How did you solve later?

@Elphaid
Copy link

Elphaid commented Apr 30, 2024

FYI: you have to put those lines before app.use(express.json());

It works

Thank you

@devlopersabbir
Copy link

devlopersabbir commented May 10, 2024

Why it's still says payload is too large??

app.use(bodyParser.json({ limit: "1024mb" }));
app.use(bodyParser.urlencoded({ extended: true, limit: "1024mb" }));
app.use(express.json({ limit: "1024mb" }));

Note: I'm using Quill Rich Editor and uploading images.

@sachinpal293
Copy link

thank u it works properly

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment