Next.js error

Updated 11 October 2026

Short answer

Next.js code runs in three places, and errors look different in each. At build time: the build fails, and the build log shows the error (type errors, failed data fetching, missing environment variables). On the server: pages return 500 errors, and the details are in your host's server or function logs. In the browser: the page breaks after loading, and the browser console shows it. Next.js uses error boundaries (error.js files) to show a fallback instead of a broken page when something throws.

What's the problem

A Next.js build fails, pages show "Application error: a server-side exception has occurred" or a 500, or parts of the page break in the browser.

Why it happens

  • Build errors: TypeScript or lint errors, a dependency problem, or data fetching that fails during the build.
  • Missing environment variables in production, especially ones the browser needs (which must be exposed at build time).
  • Server errors in server components, route handlers or server actions: a failing database or API call.
  • Browser-only errors: code using window or browser APIs during server rendering, or hydration mismatches.
  • Upgrades changing behaviour between Next.js versions.

How to fix it

  1. Work out where it fails: build log, server logs, or browser console.
  2. For build failures, run next build locally from a clean install to reproduce.
  3. For server errors, find the request in your host's logs and read the stack trace.
  4. Check environment variables for production and rebuild after changing them.
  5. Add error.js boundaries so a failing section shows a fallback.
  6. After upgrading, read the upgrade guide for breaking changes.

What Preventionlabs checks

One click runs the full report on your domain. For this problem it shows whether your site loads, how fast, and where its redirects go; up to 50 pages from your sitemap, listing any that fail or are slow, plus broken links on them. With Cloudflare connected, it also shows which pages returned server errors (5xx) to visitors, and when; recent deploys and account changes, with their times. It doesn't read your server logs, so the exact error message is in your host's logs.

Run your free report

Your first report is free, no card needed. Then A$50 a month, up to 10 domains. Read-only: it never changes anything.

Sources

  1. Next.js: Error Handlingofficial docsUncaught exceptions are unexpected errors that indicate bugs or issues that should not occur during the normal flow of your application. These should be handled by throwing errors, which will then be caught by error boundaries.

Preventionlabs is independent and not affiliated with Next.js. Product names are used only to describe the problem.

← All of Frameworks