My Nuxt site on Vercel shows 500 FUNCTION_INVOCATION_FAILED
FUNCTION_INVOCATION_FAILED: Internal Server ErrorShort answer
FUNCTION_INVOCATION_FAILED means the server function crashed while handling a request. Nuxt bundles pages and server routes into one function, so one thrown error can take down a page. Read the function log for the real error, then fix the code path, the environment variable or the legacy Nuxt 2 setup it points to.
Fix it fast
1Find out which cause you have
Open the project on Vercel, go to the Logs tab, filter to the failing path and read the first error line. That line is the cause. Everything below depends on it.
# The same logs from a terminal, with the Vercel CLI npx vercel logs <your-deployment-url>2Match what you see, then jump to its fix
- 1
A stack trace in the function log pointing at your own file under server/ or at a page's data fetchAn error is thrown and nobody catches itFix - 2
The log shows undefined values or a failed connection that works locallyThe function runs with different settings than your machineFix - 3
package.json has nuxt 2.x and the project builds with nuxt buildA legacy Nuxt 2 project is running with server-side renderingFix
- 1
What does the error look like?
FUNCTION_INVOCATION_FAILED: Internal Server ErrorVercel deploy serverless function has crashed
Cause 1 of 3
An error is thrown and nobody catches it
1Check
Vercel lists a crashed runtime and an unhandled rejection or uncaught exception as the two reasons for this error. Find the route that logs the trace and read the code around that line.
# reproduce with the production build locally
npx nuxt build
node .output/server/index.mjs2Fix
Wrap the failing call in try/catch, log the real error, and return a controlled response with an error status instead of letting the exception escape.
// server/api/items.get.ts
export default defineEventHandler(async () => {
try {
return await loadItems();
} catch (err) {
console.error('items failed:', err);
throw createError({ statusCode: 502, statusMessage: 'Upstream failed' });
}
});3Verify
Request the route again. A handled failure now returns your status and the log shows your message instead of FUNCTION_INVOCATION_FAILED.
curl -i https://your-app.vercel.app/api/itemsConfirmed by vercel.com
Cause 2 of 3
The function runs with different settings than your machine
1Check
Vercel tells you to verify the function's configuration, environment variables included. Compare the variables in Project Settings with your local .env.
npx vercel env ls2Fix
Add the missing variable for the environment that is failing, then redeploy. A new deployment is needed for the change to apply.
npx vercel env add DATABASE_URL production
npx vercel --prod3Verify
Open the page that crashed and confirm the Logs tab shows no new error.
npx vercel logs <your-deployment-url>Confirmed by vercel.com
Cause 3 of 3
A legacy Nuxt 2 project is running with server-side rendering
1Check
The Nuxt team does not recommend deploying legacy Nuxt versions such as Nuxt 2 on Vercel except as static sites. Check which Nuxt version you have.
npm ls nuxt2Fix
Either build a static site with nuxt generate, or upgrade through Nuxt Bridge or the Nuxt migration guide. Do not keep SSR on Nuxt 2 on Vercel.
# package.json
"scripts": { "build": "nuxt generate" }3Verify
Redeploy and open the site. Pages are served as static files, with no server function to crash.
curl -I https://your-app.vercel.app/Confirmed by vercel.com
How do I stop it coming back?
- Wrap external calls (database, third-party APIs) in try/catch and return a clear error response.
- Run the production build locally before pushing, so crashes show on your machine first.
- Add every environment variable to the right Vercel environment when you add it to .env.
- Keep Nuxt on a current major version if you need server-side rendering.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Web apps
tsconfig rejects allowImportingTsExtensions
An error that allowImportingTsExtensions needs noEmit or emitDeclarationOnly
allowImportingTsExtensions lets files import each other with .ts or .tsx extensions, and TypeScript only allows it together with noEmit or emitDeclarationOnly.
2 causes, each with a fixWeb apps
Apollo Server rejects a request as a potential CSRF
HTTP 400 Bad Request from the GraphQL endpoint
Apollo Server's CSRF prevention is on by default.
3 causes, each with a fixWeb apps
React shows Attempted import error when importing a component or function
Attempted import error:
The build found the file but not the name you asked for.
2 causes, each with a fixWeb apps
AxiosError Network Error with code ERR_NETWORK in a React app
Network Error
ERR_NETWORK means the request produced no readable response.
4 causes, each with a fixWeb apps
Axios get works with a URL string but ignores the object passed as the second argument
The server log shows a GET with no query string
axios.get takes a URL and an optional config object.
3 causes, each with a fixWeb apps
Can't resolve '../axios' in a React project
Module not found: Error: Can't resolve '../axios'
A path that starts with ./ or ../ is a file path, not the axios package.
3 causes, each with a fix