Troubleshooting
The most common setup problems and how to fix them, from an invalid Clerk publishable key to Stripe webhook and database errors.
The app won't start and names a missing variable
A required environment variable is missing or empty in .env. The error
names it — see Configuration for where to get it.
The app can't connect to the database
Check that the Postgres container is running (pnpm local:up) and that
DATABASE_URL and DIRECT_URL point at it.
The dashboard fails to load after sign-in
Organizations aren't enabled in Clerk. Every signed-in user must belong to
an organization; without one there's no orgId to load billing for. Enable
Organizations with Membership required — see
Setup → Configure Clerk.
Sign-in fails or Clerk's components don't render
Check that NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY and CLERK_SECRET_KEY are both
set and come from the same Clerk application and environment.
Clerk says "Publishable key not valid"
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY is still the pk_test_ placeholder from
.env.example, or the key was copied incompletely. Copy the full key from
API keys in the Clerk Dashboard.
A valid publishable key has three parts separated by underscores: pk_test_
for development or pk_live_ for production, then a base64-encoded host name
that contains a dot and ends with $. That's why pk_test_ on its own or a
made-up value like pk_test_dummy is rejected. For every version of this
error and how to fix it in production and Docker, see
Clerk publishable key errors in Next.js.
Use a placeholder key for builds and CI
When a build or CI step needs the variable set but never signs anyone in, a placeholder in the valid format passes Clerk's check:
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY=pk_test_ZXhhbXBsZS5jbGVyay5hY2NvdW50cy5kZXYkIt encodes example.clerk.accounts.dev$, which isn't a real Clerk instance,
so sign-in doesn't work with it. Anywhere a person or a test signs in, use the
development key from your Clerk application, which is free.
Docker builds are the exception: NEXT_PUBLIC_* values are compiled into the
browser code, so pass your real publishable key as a build argument. See
Docker.
Invitation emails link to *.accounts.dev instead of your app
Clerk's paths still point at its hosted Account Portal. Point the sign-in, sign-up, and sign-out paths at your app — see Setup → Configure Clerk.
Plan doesn't change after checkout
The payment went through, but the webhook that records it didn't reach the app.
- Locally:
stripe listenmust be running while you check out, andSTRIPE_WEBHOOK_SECRETmust be thewhsec_...it printed. Its output shows each event and the status your app returned. - In production: the endpoint's URL must be
https://your-domain/api/webhooks/stripe, subscribed to the five events in Stripe Setup, andSTRIPE_WEBHOOK_SECRETmust be that endpoint's signing secret.
Stripe webhook signature verification fails
STRIPE_WEBHOOK_SECRET doesn't match the sender. The secret printed by
stripe listen and a dashboard endpoint's secret are different — use the one
for where the events come from.
Checkout fails for one plan
That plan's NEXT_PUBLIC_PRICE_* variable is missing, still the
price_ placeholder, or from the other Stripe mode (test vs. live). Set it,
then restart the dev server — see Stripe Setup.
Customers can't switch plans in the billing portal
Plan switching is off by default in Stripe's customer portal — see Stripe Setup → Turn on plan switching.
Turbopack panics with "Next.js package not found"
The .next cache is stale after a fresh pnpm install. Delete .next and
restart the dev server.