# `BetterAuthError: BETTER_AUTH_SECRET is not set or is too short`

**Where it appears:** Terminal or Vercel runtime logs

**What it means:** Better Auth needs a random secret string (`BETTER_AUTH_SECRET`) to sign login cookies safely, and it hasn't been generated for this environment yet.

## Likely causes

- `BETTER_AUTH_SECRET` wasn't generated into `.env.local` or piped into `npx vercel env add` yet.
- Only Production was selected when adding `BETTER_AUTH_SECRET` in Vercel, leaving Preview without one.

## Message for your agent

```text
Better Auth says `BETTER_AUTH_SECRET` is missing. Generate a fresh random secret directly into `.env.local` and into Vercel via `npx vercel env add BETTER_AUTH_SECRET` without printing it in the chat.
```

**Prevention:** Have your agent generate `BETTER_AUTH_SECRET` unseen for both local development and Vercel as soon as logins are added.

---
Source: [Agentic Makers](https://agenticmakers.app/en/help/errors/better-auth-secret-not-set) · License: CC BY 4.0
