Built-in 500 Internal Server Error shown instead of Next.js error page

I’m running into an oddly specific issue where a page in my Next.js project returns the builtin “500 Internal Server Error” page instead of my custom error page.

This is apparently caused by the Vercel serverless function crashing during rendering rather than returning an error, but only under a specific path layout. See the minimal reproduction below.

It’s also important to note that this bug only occurs when the project is deployed on Vercel. In a local instance, the error page is shown correctly. I’m reporting this here rather than on Next’s GitHub repo as I believe it is an issue with Vercel’s infrastructure rather than Next itself.

Steps to reproduce

  1. Create a custom error page. This can be the example error.js file found on Next.js docs.
  2. Create a layout and set its dynamic property to “force-static”.
  3. Under this layout, create a page with a dynamic path segment that throws an exception when rendered.
  4. Deploy to vercel
  5. Attempt to visit the page. You should see Vercel’s own “500 | Internal Server Error” page.

Actual behavior

When visiting the page in the deployed project, the web server returns the builtin “500 | Internal Server Error” page.

Expected behavior

A custom error page is shown as defined in a error.js/tsx file.

Minimal reproduction case

You can find my reproduction case on GitHub.

Logs

Attached below is the log output from the minimal repro project when deployed on Vercel.

Vercel Logs
2025-07-18T14:28:22.275Z [error] Error: Example exception
    at d (.next/server/app/docs/[...path]/page.js:2:8176)
    at stringify (<anonymous>) {
  digest: '909818136'
}
2025-07-18T14:28:22.334Z [error] Error: Example exception
    at d (.next/server/app/docs/[...path]/page.js:2:8176)
    at stringify (<anonymous>) {
  digest: '909818136'
}
2025-07-18T14:28:22.334Z [error] ⨯ Error: Example exception
    at d (.next/server/app/docs/[...path]/page.js:2:8176)
    at stringify (<anonymous>) {
  digest: '909818136',
  page: '/docs/content'
}
2025-07-18T14:28:22.456Z [error] Error: Example exception
    at d (.next/server/app/docs/[...path]/page.js:2:8176)
    at stringify (<anonymous>) {
  digest: '909818136',
  page: '/docs/content'
}
2025-07-18T14:28:22.478Z [fatal] Node.js process exited with exit status: 1. The logs above can help with debugging the issue.

Notes

I solved this by removing the forced static render from the layout, but not without spending several hours looking for the cause. If using static rendering is not desired, Next/Vercel should inform the dev accordingly instead of showing a generic internal server error.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.