Error message · Sites on Vercel: Next.js, SvelteKit, Nuxt, Astro, Remix and plain serverless functions

“500: INTERNAL_SERVER_ERROR Code: FUNCTION_INVOCATION_FAILED”

Vercel ran your server-side code for this page or API route and it threw an error before sending a response: a crash in your code, a missing environment variable, a failed database or API call, or a timeout. Vercel shows its generic 500 page with this code and a request ID. The site's static pages usually still load; the pages and routes that run code on the server fail.

Is your site showing it right now?

The free scan loads your page like a visitor and checks for this message, plus broken links, script errors and phone layout. It also walks your signup, booking or contact form, without sending anything.

​

Free, no signup. Usually done in about a minute.

Why it happens

  • An environment variable (database URL, API key) is missing in the production environment, so the code throws on startup
  • A database or third-party API is unreachable, has rotated its credentials or hit a limit
  • A bug that only shows with real data or in production mode (undefined property, a bad date, JSON that doesn't parse)
  • A dependency that works locally but not in Vercel's runtime (native modules, a Node version mismatch, a file read from a path that doesn't exist after bundling)
  • The function ran out of memory or past its time limit (shown as FUNCTION_INVOCATION_TIMEOUT when it's the time)

How to fix it

  1. Read the runtime logs

    In the Vercel dashboard, open the project's Logs (or run vercel logs), filter by the failing path or the request ID from the error page. The stack trace there names the file and line. Fix the crash it shows; everything else below is for when the log is unclear.

  2. Compare environment variables

    Project Settings > Environment Variables: every variable your code reads must exist for Production, not only Preview or Development. After adding one, redeploy; variables are read at build and deploy time.

  3. Reproduce it locally in production mode

    Run a production build locally (for Next.js: next build then next start) with the production environment variables pulled via vercel env pull. Many crashes show only in the production build.

  4. Check the external services

    Test the database connection and API keys from a one-off script with the production values. Expired keys, a database that only allows certain IPs, and a connection limit are common after a quiet period.

  5. Roll back if visitors are waiting

    Deployments > the last good deployment > Promote to Production (or vercel rollback) puts the site back while you fix the cause. The autopilot of a monitor can't do this for you, but the fix path above takes minutes once the log is in front of you.

Questions

Why does it work locally?

Local runs use your .env file and your machine's Node version and files. Production has only the variables set in the dashboard and runs the bundled code; a variable or file missing there is the usual difference.

What's the request ID for?

Paste it into the log search to jump straight to the failing request's trace. If you contact Vercel support, give them the ID too.

Is DEPLOYMENT_NOT_FOUND the same thing?

No. That means the deployment itself is gone or the domain points at nothing. FUNCTION_INVOCATION_FAILED means the deployment is fine and your code crashed while running.

Can Page Canary tell me if this comes back?

Yes. Page Canary checks your key pages every day for this message and others like it, confirms it on a second check, and emails you with the fix. One site is free.

Other error messages