NextAuth shows 'There is a problem with the server configuration'
There is a problem with the server configuration.Short answer
That page is NextAuth's generic Configuration error: your auth setup is wrong on the server, not the browser. Check the server terminal first. The usual causes are a missing secret in production, a missing [...nextauth] route file, a Credentials provider without an authorize function, or an Email provider without a database adapter.
Fix it fast
1Find out which cause you have
Open the terminal or hosting log of the server that handles /api/auth. NextAuth prints its own error code there; match it to a cause below.
npm run build && npm run start2Match what you see, then jump to its fix
- 1
NO_SECRET: in production, we expect you to define a secret property in your configurationNo secret is set in productionFix - 2
MISSING_NEXTAUTH_API_ROUTE_ERRORThe [...nextauth] route file is missing or misnamedFix - 3
CALLBACK_CREDENTIALS_HANDLER_ERROR or CALLBACK_CREDENTIALS_JWT_ERRORCredentials provider without authorize, or with database sessionsFix - 4
EMAIL_REQUIRES_ADAPTER_ERROREmail provider without a database adapterFix - 5
UntrustedHost: Auth.js requires the trustHost option to be set to trueAuth.js v5 behind a proxy or Docker does not trust the hostFix
- 1
What does the error look like?
There is a problem with the server configuration.Check if your options are correct./api/auth/error?error=Configuration
Cause 1 of 5
No secret is set in production
1Check
The docs say a secret is expected in production (in development it is only a warning). See whether the production environment really has the variable your config reads.
grep -rn "secret" app pages lib auth.ts 2>/dev/null
printenv NEXTAUTH_SECRET | wc -c2Fix
Generate a random value, add it to the production environment and redeploy, so the server process restarts with it.
openssl rand -base64 33
# then set NEXTAUTH_SECRET=<that value> in the host's environment settings3Verify
Open the sign-in page after the redeploy; the Configuration page should be gone.
curl -I https://example.com/api/auth/signinConfirmed by next-auth.js.org
Cause 2 of 5
The [...nextauth] route file is missing or misnamed
1Check
The docs name this case: the dynamic route file must exist under pages/api/auth and be spelled exactly [...nextauth].js.
find . -path ./node_modules -prune -o -name "*nextauth*" -print2Fix
Create or rename the file so the catch-all segment is [...nextauth], and export the NextAuth handler from it.
// pages/api/auth/[...nextauth].js
import NextAuth from "next-auth"
export default NextAuth({ providers: [] /* your providers */ })3Verify
Restart the dev server and request the providers endpoint; it should return JSON.
curl http://localhost:3000/api/auth/providersConfirmed by next-auth.js.org
Cause 3 of 5
Credentials provider without authorize, or with database sessions
1Check
The docs say the Credentials provider needs an authorize() handler, and it needs JWT sessions. If you also configured a database adapter, enable JWT sessions explicitly.
grep -n -E "CredentialsProvider|authorize|strategy" pages/api/auth/*.js app/api/auth/*/route.ts 2>/dev/null2Fix
Add authorize() to the provider and set the session strategy to jwt.
session: { strategy: "jwt" },
providers: [
CredentialsProvider({
credentials: { email: {}, password: {} },
async authorize(credentials) {
// return a user object, or null to reject
return null
},
}),
],3Verify
Sign in once with a wrong password. You should get the normal sign-in error, not the Configuration page.
curl -s http://localhost:3000/api/auth/providersConfirmed by next-auth.js.org
Cause 4 of 5
Email provider without a database adapter
1Check
The docs say the Email provider needs a configured database to store verification tokens.
grep -n -E "EmailProvider|adapter" pages/api/auth/*.js app/api/auth/*/route.ts 2>/dev/null2Fix
Add a database adapter to the NextAuth options, or remove the Email provider if you do not need magic links.
// in the NextAuth options, next to providers:
adapter: yourDatabaseAdapter,3Verify
Restart the server and request the providers endpoint; the Configuration page should no longer appear.
curl -s http://localhost:3000/api/auth/providersConfirmed by next-auth.js.org
Cause 5 of 5
Auth.js v5 behind a proxy or Docker does not trust the host
1Check
Auth.js v5 reads the host from request headers, so it must be told to trust them. The docs say this is automatic on some platforms only (Vercel and Cloudflare Pages are named).
printenv | grep -E "AUTH_TRUST_HOST|AUTH_SECRET"2Fix
Set trustHost: true in the config, or the AUTH_TRUST_HOST environment variable to true.
AUTH_TRUST_HOST=true3Verify
Restart the container and request the sign-in page through the proxy.
curl -I https://example.com/api/auth/signinConfirmed by authjs.dev
How do I stop it coming back?
- Keep the auth secret in the host's environment settings and add a deploy check that fails when it is empty.
- Test sign-in against a production build (next build and next start) before every release, not only the dev server.
- Read the server log, not the browser, when an auth page shows a generic message.
Sources
How was this page made?
I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.
Which stack is behind this page?
Projects of mine built on the same technologies:
Related fixes
Web apps
Apollo Server rejects a request as a potential CSRF
HTTP 400 Bad Request from the GraphQL endpoint
Apollo Server's CSRF prevention is on by default.
3 causes, each with a fixWeb apps
Clerk cannot read its publishable key in a Next.js app
NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY is undefined
Clerk reads NEXT_PUBLIC_CLERK_PUBLISHABLE_KEY.
3 causes, each with a fixWeb apps
The shell cannot find create-next-app
command not found: create-next-app
create-next-app is not meant to be installed as a shell command.
2 causes, each with a fixWeb apps
ESLint fails with: Cannot find module 'next/babel'
ESLint stops on the first file with a Babel or parser error instead of listing lint results
next/babel is a Babel preset that ships inside the next package.
3 causes, each with a fixWeb apps
Firebase Auth says the API key is not valid
Firebase: Error (auth/api-key-not-valid.-please-pass-a-valid-api-key.)
The apiKey your app sends is either empty, wrong, or blocked.
4 causes, each with a fixWeb apps
Jest fails with SyntaxError: Unexpected token when testing a Next.js component
Jest failed to parse a file.
Jest only understands plain JavaScript until a transform and a few file mappings tell it more.
3 causes, each with a fix