Next.js Server Components render error in production
The generic Server Component error hides the real message. Recover the digest, read the server logs, and report the cause without leaking internals.

Introduction & Quick Summary
A production Next.js deployment shows users a generic crash page and the log says only this:
Error: An error occurred in the Server Components render.
The specific message is omitted in production builds to avoid leaking
sensitive details.digest: "3563520567"
Nothing in that text identifies the component, the thrown value, or the request. Next.js deliberately replaces the real message with a digest in production builds, because server error text can carry environment values, database errors, or internal paths. The error is real and it happened during server rendering of a React Server Component; only the text is hidden.
Where it appears:
- A server component throws during render, in a page, layout, or route segment.
- Data fetching inside a server component rejects and the rejection is not caught.
- A prop passed from a server component to a client component is not serializable.
- The error only reproduces on the deployment, never in
next dev.
Quick answer: take the digest from the response or the client error, find the matching line in the server logs, and fix the throw. Then add an error.tsx boundary that logs the digest with your own context so the next occurrence is one query away.
Core Mechanics, Signatures & Reproducible Setup
During a production render, Next.js catches the thrown value on the server, hashes it into a digest, and sends only the digest plus a generic message to the browser. The full error goes to the server console, which in Vercel is the function log for that invocation.
// app/dashboard/page.tsx
export default async function Page() {
const res = await fetch(process.env.API_URL!, { cache: "no-store" });
const data = await res.json(); // if API_URL is undefined, this throws
return <h1>{data.title}</h1>;
}# what the browser receives in production
{"digest":"3563520567"}
# what the function log holds
TypeError: Failed to parse URL from /api/title
at new Request (node:internal/deps/undici/undici:12756:25)
at async Page (app/dashboard/page.tsx:4:15)
digest: 3563520567The digest is the join key: it is stable for one error signature within a build, so searching the deployment logs for it returns the throwing stack.
Related messages that look similar but mean different things:
| Message | Where it comes from | What it means |
|---|---|---|
An error occurred in the Server Components render | server render, production | throw during RSC render, message redacted |
Hydration failed because the server rendered HTML didn't match | client, hydration | markup mismatch, not a server throw |
Functions cannot be passed directly to Client Components | build or render | non-serializable prop across the boundary |
Application error: a server-side exception has occurred | app router shell | the same throw, before any boundary handled it |
Error: connect ECONNREFUSED in the log only | server | real message is in logs, digest in response |
// app/broken/page.tsx
export default async function Broken() {
const value = process.env.MISSING_VALUE;
if (!value) throw new Error("MISSING_VALUE is not set");
return <p>{value}</p>;
}Run next build && next start and visit /broken: the browser shows the generic message while the terminal prints the real error with a digest.
Key Comparison Table
| Diagnosis route | What you get | Cost |
|---|---|---|
| Digest plus deployment logs | exact stack with file and line | needs log access for that deployment |
next dev reproduction | real message immediately | may not reproduce environment-specific throws |
| Structured logging in the component | your own fields next to the digest | extra code, one line per throw site |
error.tsx client boundary | digest and request path in the browser | catches segment errors, not layout errors |
global-error.tsx | catch-all for root layout throws | replaces the whole document |
| Sentry or OpenTelemetry instrumentation | stack, release, request context | setup and a third-party dependency |
Choosing where to catch:
| Boundary | Catches | Does not catch |
|---|---|---|
error.tsx in a segment | errors below that segment, client and server | errors in its own layout |
global-error.tsx | root layout and root page throws | nothing above it, it is the top |
route handler try/catch | API route throws | page render throws |
instrumentation.ts onRequestError | every server error, with digest | browser-only errors |
Practical Edge Cases, Error Fixes & Deep Dive Code Examples
1. Find the digest and match it in the deployment log
The digest reaches the client in the error object passed to a boundary, in the JSON response of the RSC request, and in the Vercel log line. Start from the boundary, because the browser holds nothing else.
// app/error.tsx
"use client";
export default function Error({
error,
reset,
}: {
error: Error & { digest?: string };
reset: () => void;
}) {
console.error("render-failed", {
digest: error.digest,
path: window.location.pathname,
at: new Date().toISOString(),
});
return (
<div>
<h2>Something failed while rendering this page.</h2>
<p>Reference: {error.digest ?? "unknown"}</p>
<button onClick={() => reset()}>Try again</button>
</div>
);
}With the digest and path in one log line, the search is one query.
2. Log the real error on the server before it is redacted
Next.js logs the full error itself, but your own logging can add the tenant, route, and input the framework does not know.
// lib/log.ts
export function logServerError(scope: string, err: unknown, extra: Record<string, unknown> = {}) {
const e = err instanceof Error ? err : new Error(String(err));
console.error("[server-error]", { scope, message: e.message, stack: e.stack, ...extra });
throw e; // let Next.js hash and redact as usual
}Call it in the catch of the page that renders the data: the log line and the framework digest land in the same invocation, so a timestamp also correlates them.
3. Distinguish a serialization failure from a render throw
Passing a function, a class instance, or a Date method across the server to client boundary fails with its own message in development, and shows up as the generic render error in production.
// fails: handler is not serializable
export default function Page() {
return <ClientCard onClick={() => console.log("x")} when={new Date()} />;
}// fix: pass data, define the handler inside the client component
export default function Page() {
return <ClientCard whenIso={new Date().toISOString()} />;
}"use client";
export function ClientCard({ whenIso }: { whenIso: string }) {
return <button onClick={() => console.log(whenIso)}>{whenIso}</button>;
}Dates, Maps, Sets, and class instances survive only as plain values. Convert at the boundary so the boundary never has to throw.
4. Catch the throw where the data enters
The most common production throw is an unvalidated response. Parse and validate at the fetch, so the failure names the endpoint instead of surfacing as a render crash.
type Report = { id: string; title: string };
async function loadReports(): Promise<Report[]> {
const res = await fetch(`${process.env.API_URL}/reports`, { cache: "no-store" });
if (!res.ok) throw new Error(`reports ${res.status}`);
const body: unknown = await res.json();
if (!Array.isArray(body)) throw new Error("reports: expected an array");
return body as Report[];
}Check the payload shape with the JSON tool before writing the guard.
5. Handle the error without hiding it
An error.tsx that returns null passes the audit and hides the incident. Return a stable message, keep the digest, and log once. Never render error.message in production: for a server throw it is the generic string, and for a client throw it can contain user input.
"use client";
export default function SegmentError({ error, reset }: { error: Error & { digest?: string }; reset: () => void }) {
return (
<section role="alert">
<h2>This section could not be loaded.</h2>
{error.digest ? <code>{error.digest}</code> : null}
<button onClick={reset}>Reload section</button>
</section>
);
}Common Compilation/Runtime Mistakes & Version Gotchas
Assuming next dev shows the same error. Development renders the real message and a stack overlay, so a bug that needs a production build or a real environment looks fine locally. Reproduce with next build && next start and the same environment before you debug.
Catching nothing because the boundary is misplaced. A segment's error.tsx does not catch a throw in its own layout.tsx. Put the boundary in the parent segment, or add global-error.tsx for the root.
Reading environment variables in a client component. process.env.X in a "use client" file is inlined at build time and is undefined at runtime for non-public names. The throw then happens during render, on the server, from a client file, and reads like a server error. Use NEXT_PUBLIC_ names deliberately, or read the value on the server and pass it down.
Swallowing the throw and returning undefined. Returning nothing from a server component produces a different error (Element type is invalid), and the original cause is now two errors away from the log.
Version differences worth knowing. Next.js 15 and 16 require await on params and searchParams in pages, layouts, and route handlers; a missing await throws at render time and arrives as a digest in production. Next.js 16 also moves request interception from middleware to the proxy file, so an auth throw may now surface as a render error. Check package.json before debugging.
Correlating with the outside world. When the crash starts at a specific minute, check the response codes with the status codes reference and diff the changed files with Diff first. Most production-only render errors follow a config or environment change, not a logic change.
Reference material: Server and Client Components and the error file convention.
Official references
primary documentationThe Next.js documentation that defines the behaviour this guide explains.
Try matching browser tools
All toolsSmall utilities that fit Next.js work — they run entirely in this browser tab, so nothing you paste leaves your device.
Related Next.js guides
All Next.js guidesModule not found: Can't resolve a package or alias in Next.js
TypeScript and the bundler resolve imports separately. Align path aliases, workspace dependencies, exports conditions and filename case.
Next.js 16 DynamicServerError: cookies(), headers() and fetchCache
Request-time APIs make a route dynamic, and Next 16 replaced the segment configs with Suspense boundaries and use cache. What to delete and what to wrap.
Next.js cacheComponents: 'used uncached or runtime data' build error
Cache Components makes the build refuse to guess where the static shell ends. Stream it, cache it with use cache, or declare the route blocking.
next/font: Failed to fetch a Google font during the build
The font is fetched during the build, not at runtime. Vendor it with next/font/local or give CI and Docker a route out.
More in Next.js
All Next.js guidesThe guides filed next to this one in Next.js, in library order.