Troubleshooting

Diagnose common setup, integration, content, and deployment failures.

Start with the smallest reproducible command, read the first meaningful error, and fix configuration at its source. Avoid committing .env, generated .source, or local build output while troubleshooting.

Install and build

SymptomLikely causeInspectSafe fix
pnpm install changes many dependencies or rejects the lockfileWrong package manager/version or edited lockfilepackage.json, pnpm-lock.yamlUse pnpm and pnpm install; do not delete the lockfile as a first step
pnpm lint reports formattingBiome diagnosticsReported file, biome.jsonRun pnpm format, review the diff, then rerun pnpm lint
pnpm build cannot resolve an alias/moduleMissing dependency, wrong casing, or stale generated contentImport path, tsconfig.json, package.jsonFix the import/dependency; regenerate Fumadocs content if the import is from .source
Development works but production build failsServer rendering reaches invalid env/data or a Client/Server boundary errorFirst failing route in build outputRun pnpm build locally and fix that route rather than suppressing the error

See Installation and Deployment.

PostgreSQL and Drizzle

SymptomLikely causeInspectSafe fix
Connection refused/timeoutPostgreSQL is stopped, host/port is wrong, or hosted DB blocks the networkDATABASE_URL, provider network policyTest the same URL with a PostgreSQL client; correct connectivity before changing schema
Authentication or database-not-found errorWrong user/password/database, often special-character escapingDATABASE_URLGenerate/copy a fresh provider URL; URL-encode credentials when constructing it manually
relation ... does not existSchema was not applied to this databasedrizzle.config.ts, src/lib/db/schema/Confirm the target database, then run pnpm exec drizzle-kit push for local/template setup
Auth breaks after editing auth schemaBetter Auth adapter expectations and Drizzle tables divergedsrc/lib/auth.ts, src/lib/db/schema/auth.tsUpdate the schema deliberately and apply it to the correct database
Too many connections in productionPer-instance pools exceed provider limitssrc/lib/db/index.ts, hosting pool settingsUse a pooled PostgreSQL endpoint and size pools for total instance concurrency

The template has no committed migration history; do not assume drizzle-kit migrate is ready. See Database.

Better Auth, cookies, and redirects

SymptomLikely causeInspectSafe fix
Login succeeds but the app still redirects to /auth/loginCookie is absent, scoped to another origin, or blocked by HTTP/HTTPS/domain mismatchBrowser cookies, BETTER_AUTH_URL, request hostUse one canonical origin; set BETTER_AUTH_URL to it and clear stale cookies
Auth endpoint returns server errorsMissing/weak secret or database/email failureBETTER_AUTH_SECRET, server logs, DATABASE_URL, Resend configGenerate a strong secret, fix the underlying service, restart the server
A protected API is reachable despite proxy assumptionssrc/proxy.ts only redirects pages based on cookie presence and skips /apiRoute Handler auth checkCall auth.api.getSession({ headers: await headers() }) inside every protected server boundary
Works locally, fails behind a proxyPublic origin/protocol is different from the configured auth URLForwarded host/proto, BETTER_AUTH_URLConfigure the canonical HTTPS URL and trusted proxy headers at the platform

See Authentication.

OAuth callbacks

SymptomLikely causeInspectSafe fix
Provider says callback/redirect mismatchRegistered URL differs by host, scheme, port, locale, or providerOAuth dashboard, BETTER_AUTH_URLRegister {BETTER_AUTH_URL}/api/auth/callback/{provider} exactly
OAuth button fails immediatelyClient ID/secret is missing or from a different app/environmentGITHUB_*, GOOGLE_*, provider dashboardUse a matching credential pair and restart after changing env vars
Account linking is unexpectedMultiple providers use the same email and linking is enabledsrc/lib/auth.tsReview the template's linking policy before changing it; test existing accounts

Resend email

SymptomLikely causeInspectSafe fix
Verification/reset/contact returns a send errorMissing RESEND_API_KEY, invalid key, or provider rejectionServer logs, .env, src/lib/email/Use a valid server-only key and retry with a permitted recipient/sender
Works with a test sender but not your domainDomain/DNS is unverified or fromEmail uses the wrong domainResend domain status, website-config.tsVerify DNS, then use a sender on that exact domain
Message accepted but not deliveredSpam/bounce/suppression or recipient issueResend delivery eventsInspect provider events; do not repeatedly retry permanent bounces

See Email.

Creem checkout and webhooks

SymptomLikely causeInspectSafe fix
Checkout creation failsSandbox/live key, server index, and product ID do not belong togetherCREEM_SERVER_IDX, CREEM_API_KEY, NEXT_PUBLIC_CREEM_PRODUCT_*Use one environment's matching key and product IDs; rebuild after changing public IDs
Webhook returns 401 Invalid signatureWrong secret, missing creem-signature, or body/proxy was alteredCREEM_WEBHOOK_SECRET, webhook endpoint/logsCopy the secret for the same Creem endpoint and send the raw provider request directly
Webhook returns 500 about configurationSecret is unset at runtimeRuntime envSet CREEM_WEBHOOK_SECRET on the running deployment and restart/redeploy
Payment succeeds but UI remains unchangedEvent not handled, webhook not delivered, or dashboard page is still mockCreem delivery log, /api/payment/notify/creem, DB rowsReplay a verified sandbox event; inspect order/subscription rows; connect the UI to those rows

Use the exact webhook path /api/payment/notify/creem. See Payments.

OpenAI chat

SymptomLikely causeInspectSafe fix
Missing/invalid API keyOPENAI_API_KEY is absent or invalidServer env and route logsSet a valid server-only key and restart
Model not found/unsupportedClient picker/model string is unavailable through the configured providerChatBot.tsx, /api/chat requestChoose a supported model and enforce the same allowlist server-side
Search toggle returns no web resultsCurrent code sends tools: {}src/app/api/chat/route.tsConfigure a real server-side search tool or remove/disable the toggle
Stream stops with little UI feedbackProvider/connection error is not mapped into a product error stateNetwork response and server logsAdd structured stream error handling, timeouts, and user-safe feedback

See AI Chat.

Replicate media

SymptomLikely causeInspectSafe fix
Provider “not configured”REPLICATE_API_TOKEN was missing when the lazy factory was createdRuntime env, src/lib/ai/*/index.tsSet the token and restart the process
Prediction creation returns 500Invalid model ID or model-specific input mappingRoute logs, provider implementation, Replicate prediction errorCompare createTask() input with that model's schema; do not blindly pass UI options
Polling never finishesRemote job is slow/stuck, status is unknown, or client has no overall timeout/query response, Replicate taskInspect the task at Replicate; add bounded backoff, timeout, cancellation, and persistence
Success has no visible mediaOutput shape is not recognized or provider URL expired/CORS blocks downloadtaskInfo.output, URL extractorExtend the relevant extractor; copy final assets to your own object storage

See AI Media.

Fumadocs and MDX

SymptomLikely causeInspectSafe fix
Collection import or .source type is missingGenerated directory is stale/absent.source/, source.config.ts, tsconfig.jsonStop dev, remove .source/, run pnpm dev or pnpm build
Build reports invalid frontmatterRequired schema field has wrong type/formatFailing MDX file, source.config.tsCorrect frontmatter; dates use YYYY-MM-DD, tags are arrays
Docs page is 404 or absent from navFile/translation is missing or meta.json slug is wrongcontent/docs/, nearest meta.jsonCreate the page pair and make the exact filename match the navigation slug
MDX component is undefinedComponent is not in the map passed by that renderermdx-components.tsx, docs/blog/legal pageRegister and pass a shared component map to the relevant renderer

Do not edit .source by hand. See Content.

Internationalized routing

SymptomLikely causeInspectSafe fix
/en/... redirects or links look inconsistentDefault English locale uses localePrefix: "as-needed"src/i18n/routing.ts, navigation helpersUse @/i18n/navigation; expect English without /en and Chinese with /zh
New locale 404sLocale was added in only one place or messages/content are missingrouting, request config, messages, proxy regexUpdate every locale list and provide messages/content before linking it
API requests are unexpectedly localizedAPI was routed through locale middlewaresrc/proxy.ts matcher/early API returnKeep /api excluded from locale handling

See Internationalization.

Docker

SymptomLikely causeInspectSafe fix
Container exits because server.js is missingApp was not built with standalone output or wrong stage/artifact was copiednext.config.mjs, Docker build logKeep output: "standalone" and rebuild the provided multi-stage Dockerfile
Container runs but cannot reach PostgreSQLlocalhost points to the container itselfRuntime DATABASE_URL, Docker networkUse the database service hostname/host gateway and test from the same network
Public config is stale despite runtime env changeNEXT_PUBLIC_* was inlined during pnpm buildBuilder-stage env and deployment artifactSupply public values at build time and rebuild the image
Uploaded files disappearpublic/uploads is inside an ephemeral/replaced containerUpload route and volumesReplace local writes with durable object storage; a volume alone still needs multi-instance design

See Deployment and Storage.

Next.js 16 checks

  • Async request APIs: type params and searchParams as promises and await them. Also await headers() and cookies().
  • proxy.ts, not middleware.ts: this template uses the Next.js 16 proxy convention. Do not add a second legacy middleware file from an old tutorial.
  • Server/Client boundaries: Client Components cannot be async; browser hooks need "use client"; props crossing from server to client must be serializable. Keep secrets/database code server-only.
  • Build-time public env: changing NEXT_PUBLIC_* after a build does not update the browser bundle. Rebuild/redeploy.

If a problem persists, capture the failing command, first relevant stack frame, route, HTTP status/response, and redacted environment variable names—not secret values. That is usually enough to make the next debugging pass decisive.

On this page