Free auditStart free
GuideError · HTTP status codes

413 Payload Too Large in Express

Fix an Express 413: raise the express.json limit from its 100kb default, read the entity.too.large error, handle multer limits and check the proxy in front.

3 min
read
7
sources
Oct 29, 2026
updated
Scaplet Editorial Team
author
The short answer

In Express a 413 comes from body parsing. express.json() and express.urlencoded() reject bodies over their limit, which defaults to '100kb', with an error whose status is 413 and type is 'entity.too.large'. Raise the limit on the route that needs it, or move uploads to multer, and check any proxy in front.

  1. The error and where it comes from
  2. Fix it on the route that needs it
  3. Multipart uploads use multer
  4. Check what is in front of Express
  5. Test the limit without guessing
30-second check

Where does your site stand?

Four quick questions, then a straight answer.

1/4Have you checked your own site for this?
Summarize this page withChatGPTClaudePerplexityGoogleAI Mode
02Check it

Fix it on the route that needs it

Order matters: a parser mounted earlier on a path handles the body first. Mount the high-limit parser on the specific path before the global one, as above, so large payloads are not rejected by the default parser.

Return a useful 413 instead of the default page
app.use((err, req, res, next) => {
  if (err.type === 'entity.too.large') {
    return res.status(413).json({ error: 'Body too large', limit: err.limit });
  }
  next(err);
});
Small default globally, larger limit only where needed
import express from 'express';
const app = express();

// everything else stays at the 100kb default
app.use('/import', express.json({ limit: '5mb' }));
app.use(express.json());

app.post('/import', (req, res) => res.json({ ok: true }));
03Good to know

Multipart uploads use multer

express.json() does not parse multipart forms. File uploads usually go through multer, which has its own limits. Its fileSize default is Infinity, fieldSize is 1MB, and exceeding a limit raises a MulterError with a code such as LIMIT_FILE_SIZE. That error is not an entity.too.large error, so handle it separately.
multer with a size limit and error handling
import multer from 'multer';
const upload = multer({ dest: 'uploads/', limits: { fileSize: 10 * 1024 * 1024 } });

app.post('/avatar', (req, res) => {
  upload.single('avatar')(req, res, (err) => {
    if (err instanceof multer.MulterError) {
      return res.status(413).json({ code: err.code });
    }
    if (err) return res.status(500).end();
    res.json({ ok: true });
  });
});
04How it works

Check what is in front of Express

Other 413 sources in a typical stack
LayerWhere to look
nginxclient_max_body_size, default 1m; see 413 in nginx
ApacheLimitRequestBody; see 413 in Apache
IISmaxAllowedContentLength; see 413 in IIS
  1. 01

    Reproduce

    curl -i -X POST -H 'Content-Type: application/json' --data-binary @big.json http://localhost:3000/import.

  2. 02

    Read the headers

    A 413 with an HTML body and a Server: nginx header came from the proxy, not Express.

  3. 03

    Hit Express directly

    Call the app port without the proxy. If it passes, raise the proxy limit instead of the parser limit.

05Check it

Test the limit without guessing

With the default limit you should see your route's normal status for the first file and 413 for the second. If both fail, something other than body-parser is rejecting the request. If both pass, your limit is higher than you think, so look for another express.json() call earlier in the stack.

  • Wrong content type: a parser only reads bodies whose Content-Type matches its type option, so a mismatched type leaves req.body undefined rather than returning 413.
Generate bodies just under and just over 100kb
node -e "console.log(JSON.stringify({d:'x'.repeat(90*1024)}))" > under.json
node -e "console.log(JSON.stringify({d:'x'.repeat(110*1024)}))" > over.json

curl -s -o /dev/null -w '%{http_code}\n' -X POST -H 'Content-Type: application/json' --data-binary @under.json http://localhost:3000/
curl -s -o /dev/null -w '%{http_code}\n' -X POST -H 'Content-Type: application/json' --data-binary @over.json http://localhost:3000/
06Explained

SEO and crawler notes

This is an API and form problem. Googlebot sends GET requests without bodies, so it normally never hits the body limit. Google treats any 4xx other than 429 the same way: it does not index the URL. See 413 Request Entity Too Large.
Sources · 7

Every fact, linked and dated.

Official docs first. The date is when we last opened each page.
  • rfc-editor.org
  • expressjs.com
  • githubusercontent.com
  • google.com
  1. 01RFC 9110: HTTP Semanticsrfc-editor.org · checked 2026-11-01
  2. 02Express: body-parser middlewareexpressjs.com · checked 2026-11-01
  3. 03body-parser READMEraw.githubusercontent.com · checked 2026-11-01
  4. 04Express: error handlingexpressjs.com · checked 2026-11-01
  5. 05Express: multer middlewareexpressjs.com · checked 2026-11-01
  6. 06multer READMEraw.githubusercontent.com · checked 2026-11-01
  7. 07How HTTP status codes affect Google's crawlersdevelopers.google.com · checked 2026-11-01
Questions

Asked a lot.

3 questions people ask next, answered from the sources on this page.

01What is the default body size limit in Express?

express.json() and express.urlencoded() use body-parser, whose limit option defaults to '100kb'. Bodies over it produce a 413 error of type entity.too.large.

02How do I increase the limit?

Pass a larger limit to the parser, for example express.json({ limit: '5mb' }), ideally only on the route that needs it. The docs recommend using the default whenever possible.

03Why do file uploads still fail after I raised the limit?

Multipart uploads are parsed by multer, which has separate limits. A proxy in front of Express can also enforce a smaller limit and return its own 413.

Free · 2 minutes

Tools point. Agencies advise. This one ships.

Run the free audit, then approve the fixes. Every change can be undone.

Free, no card60 secondsNobody will call you
  • 46 fixes shipped without a ticket Brightpipe
  • 0→7 ChatGPT citations in six weeks Paylane