Replit app works in Preview but breaks when published? Add production secrets
Ship ItChecked against the official source
Source checked 10 Oct 2026 · Published 23 Oct 2026 · Last reviewed 23 Oct 2026 · By Ctrl+Z Therapy (how we test)
The short answer
Replit's troubleshooting docs say secrets you set in the Project Editor do not automatically carry over to your published app. Missing secrets can cause errors about undefined values, failed API calls, database connection failures, login errors, or payment failures. The fix is to add all production secrets and environment variables in the Publishing pane, then republish.
What to do
- In Replit, open Publishing, select Adjust settings, and find Production app secrets.
- Add every secret your app reads. Use live values there if they differ, like live payment keys.
- Republish your app.
- Ask your AI tool: "List every secret and environment variable this app reads, so I can add each one to Replit's Production app secrets before publishing."
Good to know
- If Preview itself is broken, Replit says publishing will not fix it. Start with Preview.
- Secrets work for all deployment types except Static Deployments.
Source
Checked on 10 Oct 2026. Prices, limits and settings change, so check the source before you rely on them.