Vercel deployment error: Environment Variable references Secret which does not exist

Deployment·Sep 12, 2026·beginner·
Quick answer

An environment variable your app needs isn't set in your Vercel project settings for the environment you're deploying to (Production/Preview/Development each have separate values). Add it under Project Settings → Environment Variables, then redeploy.

What causes this error

Vercel scopes environment variables separately per environment — a variable set for Production won't automatically apply to Preview deployments (e.g. from a pull request) or local `vercel dev`. This trips people up constantly since it works fine locally with a `.env` file.

The Fix

  1. Go to your Vercel project → Settings → Environment Variables
  2. Add the missing variable, and check the boxes for every environment that needs it (Production, Preview, Development)
  3. Redeploy — existing deployments don't pick up new env vars retroactively

Common causes / variations

  • Variable added only to Production, but the error happens on a Preview deployment
  • Variable name typo between `.env.local` and what's referenced in code
  • Using an old-style Vercel 'Secret' reference (`@secret-name`) which is deprecated in favor of plain environment variables

Related errors

See also: NEXT_PUBLIC_ variable undefined in production.

Was this fix helpful?

Comments

Loading comments...

Fix: Vercel Environment Variable not found error | BugFixer | BugFixer