# `500: INTERNAL_SERVER_ERROR — Code: FUNCTION_INVOCATION_FAILED`

**Where it appears:** Preview or Production site on Vercel

**What it means:** Something crashed on the server while handling your request. Vercel hides the raw crash from visitors and records the real cause in the runtime logs.

## Likely causes

- A required environment variable (like `DATABASE_URL` or `BETTER_AUTH_SECRET`) is missing in Preview or Production.
- An unexpected database or third-party error was thrown without an error boundary or friendly return value.

## Message for your agent

```text
The live or Preview site shows `500 FUNCTION_INVOCATION_FAILED`. Check the runtime logs with `npx vercel logs` and compare environment variable names with `npx vercel env ls` (never values).
```

**Prevention:** Add `error.tsx` and `global-error.tsx`, and verify environment variable names in both Preview and Production before publishing.

---
Source: [Agentic Makers](https://agenticmakers.app/en/help/errors/500-internal-server-error-function-invocation-failed) · License: CC BY 4.0
