Vercel Environment Variables Not Working (Undefined)
Ongoing Web, Vercel CLI Updated October 21, 2026
Quick answer
Vercel only applies environment variable changes to new deployments, and only to the environments you ticked. Redeploy after every change, check the Production/Preview scope, and remember NEXT_PUBLIC_ variables are baked in at build time.
Most likely fix: Redeploy after changing variables.
Symptoms
process.env.MY_VAR is undefined in production or preview, a NEXT_PUBLIC_ value is missing in the browser, or the build fails because a variable is undefined.
Why it happens
- Variable added after the last deployment (no redeploy)
- Variable scoped to Production but you are on a Preview deployment, or vice versa
- Branch-specific Preview variable overriding the general one
- NEXT_PUBLIC_ variable missing at build time, so it is inlined as undefined
- Monorepo/Turborepo not passing variables to the build task
- Edge runtime limit of 5 KB per variable (64 KB total per deployment)
How to fix it
Try these in order — the most common fix is first.
1. Redeploy after changing variables
- Settings > Environment Variables: confirm the variable is saved
- Go to Deployments, open the latest deployment and click Redeploy
- Changes never apply to existing deployments
2. Check the environment scope
- Edit the variable and confirm Production, Preview and/or Development are ticked
- For preview branches, check for a branch-specific value overriding it
3. Fix NEXT_PUBLIC_ variables
- Make sure the variable exists before the build runs
- Use the exact NEXT_PUBLIC_ prefix
- Redeploy without build cache if the old value persists
4. Sync local development
- Run vercel env pull to write Development variables to .env
- Or use vercel dev, which loads them automatically
5. Monorepos
- Declare the variables in turbo.json env/globalEnv for the build task
- Confirm the project's Root Directory is the app that reads the variable
This guide also covers
- vercel environment variables not working
- vercel env undefined
- next_public env undefined vercel
- vercel env variables not updating
- vercel env pull
Still not working?
If Vercel keeps failing, you're not alone. See every Vercel problem users report or the alternatives people switch to.
Other Vercel errors
- Vercel Deployment Failed: Build Error
- Vercel 404 NOT_FOUND After Deploy
- Vercel FUNCTION_INVOCATION_TIMEOUT (504) Error
- Vercel Build Exceeded Memory (SIGKILL / Out of Memory)
- Vercel Domain Not Verifying (Invalid Configuration)
- Vercel Unexpected Bill: Why Usage Charges Spiked
- Vercel Deployment Blocked: Commit Author Does Not Have Access
- Vercel Not Deploying After Git Push
- Vercel ERR_TOO_MANY_REDIRECTS With Cloudflare
- Vercel 500 FUNCTION_INVOCATION_FAILED Error
- Vercel 413 FUNCTION_PAYLOAD_TOO_LARGE (4.5 MB Limit)
- Vercel Project Paused or Account Blocked