Replit app not working? Fixing preview and publishing problems
Last reviewed 3 November 2026
It runs in Preview, then fails when you publish. Or it publishes, and the live link is broken. Most of these problems fit a short list of causes, so check them in order before you spend more on Agent.
Start with Preview: if that’s broken, publishing won’t fix it. If Preview works but publishing fails, read the logs in the Publishing pane and check your production Secrets, which don’t copy over automatically. If the public link is broken, compare your live settings and database with those in Preview.
Step 1: Does it work in Preview?
This is the question Replit’s own troubleshooting guide starts with. Select Run and open Preview.
- Preview is broken: fix that first. Ask Agent to check the run command, dependencies, app errors, ports and missing Secrets, to fix the smallest issue first, and to tell you how to verify it.
- Preview works: your problem is in the publishing setup, so carry on.
Step 2: Preview works, but publishing fails
Open the Logs tab in the Publishing pane and copy the error. Then check these, based on Replit’s guide:
| Check | Why it fails | What to do |
|---|---|---|
| Production Secrets | Secrets set in the editor don’t carry over to your published app. This causes undefined values and failed sign-in, database or payment calls | Add every one in the Publishing pane |
| Run and build commands | Typos, a wrong entry file, or commands that only work in development | Check both in the Publishing pane |
| Long-running process | A published app is expected to keep running. If it runs once and exits, it gets restarted | Make sure it starts a web server |
| Host and port | The server has to listen on 0.0.0.0, not only localhost | Ask Agent to check, and to change nothing else |
| Slow homepage | Replit sends a request before going live. A homepage taking over five seconds can time out, and publishing fails at the last step | Move slow work behind a user action, or cache it |
Step 3: It published, but the live link is broken
Now compare Preview with the live version:
- Data saves in Preview but not live. Replit’s managed database can have separate development and production environments. Ask Agent to confirm the production database is connected to the published app.
- Files disappear. Files written locally by the app may not persist, so use a database or storage service.
- Sign-in or payment returns to the wrong place. Redirect addresses often still point to the development link. Check your sign-in and payment provider settings.
- Live data looks empty. Your test data may be in the development database, which is often how it should be.
Replit also suggests asking Agent to compare Preview and production, including Secrets, database settings, API calls, login and payment redirects, build output and logs. Telling it not to change app behaviour beyond the fix helps keep changes small.
Be careful with your live database
AI agents are good at changing things, including things you didn’t want changed. Before Agent does anything that touches real customers’ data, take a backup, make sure you’re working in development, and read what it plans to do. If something goes wrong in code, Replit’s Agent checkpoints and version control can take you back, but don’t assume your live data comes back with them.
Keep your costs and code under control
- Don’t let the Agent loop. If it has tried the same fix twice, stop, and give it the exact log output with a narrower task. Agent use is billed, so loops cost money.
- Check your running costs. Publishing and databases are billed separately from building.
- Keep a copy of your code in your own Git repository.
- Run the security checklist before you take on real customers.
When to get help
Get a developer involved when real customers or payments are affected, when fixes keep breaking other things, or when you can’t tell what’s in production. A short audit is usually cheaper than more guessing. See how we make AI-built apps ready for real customers.
Questions founders ask
Why does my Replit app work in Preview but not when published?
Most often it’s because production Secrets weren’t added in the Publishing pane, the server isn’t listening on 0.0.0.0, or the live app uses a different database from Preview.
Can I publish a Replit app to the App Store?
Replit has a mobile route and documents uploading to App Store Connect. Apple’s review still applies, so read what Apple will check first.
Can I move my app off Replit later?
Usually, since it’s your code, though databases and secrets need moving too and some Replit services may need replacing. Ask a developer to review this before you rely on a move.