500: INTERNAL_SERVER_ERROR / FUNCTION_INVOCATION_FAILED on Vercel
On this page
Short answer
Your server code crashed while it was handling the request. Vercel lists two causes: the runtime process crashed, or the code threw "an unhandled rejection/uncaught exception." The page only tells you that it crashed. The cause is in the function's runtime log, so read that before you change any code.
Find a fix pack
Checklists and prompts for Supabase security, Stripe payments and deploys. Each pack is $24, or $49 for all three.
The exact error you'll see
The visitor sees a Vercel error page. This text is from a page quoted in a vercel/next.js GitHub issue. The ID: line that follows differs for each request.
This Serverless Function has crashed.
Your connection is working correctly.
Vercel is working correctly.
500: INTERNAL_SERVER_ERROR
Code: FUNCTION_INVOCATION_FAILED
Source: https:/
Vercel's error reference lists the code with status 500:
FUNCTION_INVOCATION_FAILED
Source: https:/
Applies to
- Vercel Functions on the Node.js runtime: Next.js API routes, route handlers and server rendering, plus
/apifunctions in Vite apps made with v0, Lovable, Bolt or Cursor - Node.js versions Vercel currently offers: 26.x (default), 24.x and 22.x, set in Project Settings or
engines.nodeinpackage.json - Settings involved: Environment Variables, the Node.js Version setting, and runtime logs
Why it happens
- An exception nobody caught. Vercel's troubleshooting steps say to look for "any unhandled exceptions within the function code."
- Missing or wrong configuration. Vercel says to check "the function configuration... including any environment variables." A variable that is
undefinedat run time can make the code throw. - An environment change that never reached the live deployment. Vercel says variable changes "are not applied to previous deployments, they only apply to new deployments."
- A Node version mismatch.
engines.nodeinpackage.jsonoverrides the version selected in Project Settings.
How to fix it, step by step
- Reproduce the error once and note the time.
- Open the project's Logs and filter by HTTP status code 500 and by Request Path. Vercel supports both filters, plus deployment and environment. Open the matching request and read the first error and its stack trace.
- If the stack trace names a missing value, open Settings → Environment Variables, confirm the exact name, and confirm it is set for the right environment (Production or Preview). Then redeploy, because a saved change alone doesn't reach the running deployment.
- If it's a module or syntax error, check the Node version. In Settings → Build and Deployment → Node.js Version, compare it with
engines.nodeinpackage.json. To confirm what actually ran, Vercel suggests loggingprocess.versioninside the function. - If it's an error from your own code or an upstream call, wrap that call so the function returns a clear 4xx or 5xx response instead of crashing. Vercel's steps suggest a try/catch block. Don't swallow the error silently.
- To test without deploying, run
vercel dev. Vercel says it replicates "the Vercel deployment environment locally." For Next.js, Vercel saysnext devalready covers Functions, so prefer that. - Redeploy and repeat the exact failing request, not just the homepage.
What the docs don't spell out
- On Hobby, the evidence expires fast. Vercel keeps runtime logs for "1 hour" on Hobby and "1 day" on Pro. Reproduce the error, then read the log right away. (Runtime logs (opens in a new tab))
- Huge logs get cut off. Each request can log up to 1 MB and 256 log lines. If you dump large objects, the line with the real error may be missing. Log the error message and stack instead. (Runtime logs (opens in a new tab))
- Node minor versions can differ. Vercel says "the exact minor version can differ between the build and the function runtime." A build that passes doesn't prove the function runs on the same Node release. (Node.js versions (opens in a new tab))
How to check it worked
- The original failing request now returns the expected status, not 500.
- The Logs view, filtered to that path and status 500, shows no new entries after the redeploy.
- If you changed variables, the deployment you're testing was created after the change.
Sources
- https:/
/ : definition, 500 status, possible causes, troubleshooting stepsvercel. com/ docs/ errors/ FUNCTION_ INVOCATION_ FAILED (opens in a new tab) - https:/
/ : exact text of the visitor-facing crash pagegithub. com/ vercel/ next. js/ issues/ 40065 (opens in a new tab) - https:/
/ : log filters, retention by plan, per-request log limitsvercel. com/ docs/ logs/ runtime (opens in a new tab) - https:/
/ : changes apply only to new deployments; per-environment scopingvercel. com/ docs/ environment- variables (opens in a new tab) - https:/
/ : available versions, settings path,vercel. com/ docs/ functions/ runtimes/ node- js/ node- js- versions (opens in a new tab) engines.nodeoverride,process.version - https:/
/ :vercel. com/ docs/ cli/ dev (opens in a new tab) vercel devpurpose, andnext devfor Next.js
Related fixes
Tool to consider: Better Stack.
Find a fix pack
Checklists and prompts for Supabase security, Stripe payments and deploys. Each pack is $24, or $49 for all three.