Common Issues
deployment
Environment Variables Not Working in Production
Your app works perfectly on your local machine or in the AI tool's preview, but in production it fails. The cause is almost always missing or misconfigured environment variables โ API keys, database URLs, and secrets that the app needs to function.
Common Causes
- Environment variables not set in the hosting platform (Vercel, Netlify, Railway, Render)
- Variable names are different between .env file and hosting platform
- The .env file was committed to git with wrong values for production
- Environment variables not available at build time (some frameworks require this)
- The app reads from process.env but the hosting platform uses a different mechanism
How to Fix It
- List all variables in your .env file and verify each one is set in your hosting platform
- Check that variable names match exactly (they're case-sensitive)
- Some frameworks require env vars prefixed with NEXT_PUBLIC_ or VITE_ to be available in the browser
- After adding env vars, redeploy โ most platforms require a redeploy for changes to take effect
- Check deployment logs for messages about missing configuration
Real developers can help you.
Describe what's wrong in plain English. No technical knowledge needed.
Get HelpFrequently Asked Questions
The app works on my computer but not after deploy. Is it env vars?
Very likely. This is the #1 cause of 'works locally, breaks in production'. Check that all environment variables from your .env file are set in your hosting platform.
I set the env vars but it still doesn't work. What else could it be?
Make sure you redeployed after adding them. Also check that the variable names match exactly (case-sensitive) and that any framework-required prefixes are included.