Skip to content

Next.js Server Action errorNext.js Server Action fails on uploads over 1 MB

A form or file upload that goes through a Server Action works with small files and fails with bigger ones. In our experience the error reads “Body exceeded 1 MB limit”. Next.js caps the request body for Server Actions by default. Here is what Next.js documents, and the fix, or hand it over at a fixed price.

Short answer

For forms that are only a little over 1 MB, raise serverActions.bodySizeLimit in next.config.js and leave some room for the upload overhead. For real files, such as photos or PDFs, upload from the browser straight to storage and send only the file’s address to the Server Action. On Vercel, a function can’t take a body over 4.5 MB whatever the setting.

Why the Server Action fails, and the fix

  1. 01

    The request is over the default 1 MB

    “By default, the maximum size of the request body sent to a Server Action is 1MB” Next.js, serverActions

    Server Actions accept 1 MB by default, and a photo from a phone is often larger. Next.js lets you raise the limit in next.config.js.

    /** @type {import('next').NextConfig} */
    module.exports = {
      experimental: {
        serverActions: {
          bodySizeLimit: '2mb',
        },
      },
    }
  2. 02

    The limit is raised, but uploads near it still fail

    “If you expect uploads close to the configured value, leave some room for this overhead.” Next.js, serverActions

    Form uploads add boundaries and headers to the body, so a file just under the limit can still go over it. Set the limit with some room to spare.

  3. 03

    The app runs on Vercel and the file is bigger than 4.5 MB

    “The maximum payload size for the request body or the response body of a Vercel Function is 4.5 MB.” Vercel, Functions limits

    Raising bodySizeLimit doesn’t lift Vercel’s own cap on a function’s request body. Upload big files from the browser straight to storage, such as Vercel Blob client uploads or a signed upload URL, and pass only the file’s address to the Server Action.

Checked against the vendor’s docs on : Next.js docs: serverActions; Vercel docs: Functions limits.

Rather hand it over?

Fixed scope, fixed price, paid upfront. The work happens in writing; no call needed.

Related: Vercel 413 payload too large · Next.js image hostname not configured · Next.js DynamicServerError · Next.js hydration error

Questions

More on this error

Should we just set the limit very high?

Next.js keeps the limit low to stop large requests from using up server resources and to limit abuse. Raise it only as far as your real forms need, and send big files straight to storage.

Can you fix it for me?

If one bug is the whole problem, the App Fix Ticket covers it: a written diagnosis first, then the fix. If the app has more going on, the Launch Check is a written check of the whole app. Each issue found is rated critical, high, medium or low, with where it is and how it was confirmed. No issues worth fixing, no charge. If the Launch Check finds nothing rated medium or higher, Simon refunds the full $450. You keep the report either way.

A different error?

Describe it and get a written quote

Send the error and what you were doing. You get a written scope, a fixed price and a timeline; we reply by email, usually within one business day.