Skip to content
Latchkey

Nuxt "500 ... Error during prerendering" in CI

During nuxt generate or prerendering, Nitro renders each route to static HTML. If a route throws (a fetch returns 500, an env var is missing, or server-only code runs in the wrong place), the prerender pass fails the build.

What this error means

nuxt build / generate fails with "[nitro] ERROR Error: 500 ..." and a route path, naming the page that threw during prerendering. Dev mode rendered it without erroring.

nuxt
ERROR Error: 500 [GET] "/api/posts": <no response>
  at $fetch (node_modules/ofetch/dist/...)
  while prerendering /blog

Common causes

A data fetch fails at build time

A page calls an API that is unreachable or returns 500 during the build, so prerendering the page throws.

Missing build-time environment configuration

An env var or runtime config the page relies on is absent in CI, so the render path errors.

How to fix it

Make the failing fetch resilient or skip it

  1. Read the route path and the failing request in the error.
  2. Ensure the API is reachable at build time, or handle its failure in the page.
  3. Exclude routes that cannot be prerendered from the prerender list.
nuxt.config.ts
export default defineNuxtConfig({
  nitro: { prerender: { failOnError: false, ignore: ['/dynamic'] } }
});

Provide required env at build time

Inject the env vars and runtime config the prerendered pages need.

.github/workflows/ci.yml
env:
  NUXT_API_BASE: https://api.example.com

How to prevent it

  • Ensure build-time data sources are reachable during prerender.
  • Handle fetch failures gracefully in prerendered pages.
  • Exclude genuinely dynamic routes from the prerender list.

Frequently asked questions

What causes ""500 ... during prerendering""?
A page calls an API that is unreachable or returns 500 during the build, so prerendering the page throws.
How do I fix "500 ... during prerendering"?
Make the failing fetch resilient or skip it

Related guides

References

Latchkey auto-heals failures like this one - detected, fixed, and retried without you. Start free → 30-day trial · No credit card