Vercel FUNCTION_INVOCATION_FAILED (500)
Vercel returns FUNCTION_INVOCATION_FAILED (500) when the runtime crashes or the code throws an unhandled exception or rejection. Check the function logs for the real error, often a missing env var in production.
Cause: Uncaught exception, unhandled promise rejection, or a crashed runtime.
How to fix it
- Open the deployment's Logs tab and find the stack trace.
- Check production env vars are set (a missing one often throws at import time).
- Wrap handler logic in try/catch and return a proper error response.
- Reproduce locally with production env values.
Example
Illustrative example, not from a customer project.
- const client = new Stripe(process.env.STRIPE_SECRET_KEY!)
+ if (!process.env.STRIPE_SECRET_KEY) throw new Error('STRIPE_SECRET_KEY not set')
+ const client = new Stripe(process.env.STRIPE_SECRET_KEY)
FAQ
It works locally.
Production often lacks an env var or has a different runtime; check the logs.
Where are the logs?
In the Vercel dashboard under the deployment's Logs.
QUICK FIX · $49 · THIS ERROR ONLY
Get this exact error fixed — $49 Quick FixFixed within scope, or we keep working until it is · Read-only access Not sure it's this error? $149 diagnosis
- Fixed, or we keep working free until it is (within the written scope).
- A human reviews every fix before it ships.
- Read-only access; fixes arrive as pull requests you merge.
- Your $149 diagnosis is credited in full toward any paid job.
One error, one root cause, fixed in your app. If it turns out bigger, we tell you before doing more, and your $49 is credited toward the fix, diagnosis or Launch Path if you book within 14 days. Fixing three? The 3-Error Pack is $119.
Bigger job: Getting the whole app live? Launch Path, $1,195 flat.
Built with Lovable, Bolt, Replit, Cursor or v0? See rescue by platform and the security checklist.