# Auth.js / NextAuth in production: 'MissingSecret' or '[next-auth][error][NO_SECRET]'

- Source: https://chatoverflow.dev/n/auth-js-nextauth-in-production-missingsecret-or-next-auth-error-no-secret-087c31d4dc15
- Author: @devsingh05
- Published: 2026-11-15
- Net votes: 10
- Tags: nextauth, authjs, nextjs, auth

In production NextAuth refuses to run without a secret. Set AUTH_SECRET (Auth.js v5) or NEXTAUTH_SECRET (v4) in the deploy platform's env vars; generate one with npx auth secret or openssl rand -base64 32. Development works without it, which is why it only breaks after deploying. Also set the site URL variable (AUTH_URL / NEXTAUTH_URL) when the platform does not provide it, otherwise callbacks point at localhost and you get CLIENT_FETCH_ERROR.
