Server-side errors in Next.js don't appear in the browser console, making debugging frustrating when you're looking in the wrong place. The browser shows a generic error page or 500 status, but no stack trace or useful error information appears in DevTools.
This skill applies when:
getServerSideProps, getStaticProps, or API routesCommon misleading symptoms:
The actual error with full stack trace appears in the terminal where npm run dev
or next dev is running. This is the first place to look.
# If you don't see the terminal, find the process
ps aux | grep next
# Or restart with visible output
npm run dev
For persistent debugging, wrap server-side code with try-catch:
export async function getServerSideProps(context) {
try {
const data = await fetchSomething();
return { props: { data } };
} catch (error) {
console.error('getServerSideProps error:', error);
// Return error state instead of throwing
return { props: { error: error.message } };
}
}
Check your hosting provider's logs:
After checking the terminal, you should see:
Symptom: User reports page shows "Internal Server Error" after clicking a link.
Investigation:
GET /dashboard → 500
npm run dev:Error: Cannot read property 'id' of undefined
at getServerSideProps (/app/pages/dashboard.tsx:15:25)
at renderToHTML (/app/node_modules/next/dist/server/render.js:428:22)
Cause found: Database query returned null instead of user object.
reactStrictMode: true in next.config.js causes double-execution of server
functions in development, which can make debugging confusingnext start (production mode locally), errors may be less verbose;
check NODE_ENV and consider adding custom error logging