Home / Fix guides
Replit

Replit app works in Preview but publishing fails or the live URL is broken

Updated 2026-11-11

Publishing fails at the final step / the published replit.app URL errors while Preview works

What you see

Everything runs in the Replit Preview pane. You hit Publish, and either the publish fails near the end, or it succeeds but the public replit.app URL shows errors, blank data or failed logins.

Replit’s own troubleshooting guide starts with one rule: if Preview is broken, publishing will not fix it. Get Preview working first, then go through the checks below in order.

1. Your server listens on localhost

Replit says published web servers must listen on 0.0.0.0. A server bound to localhost or 127.0.0.1 does not work once published.

// Express
app.listen(process.env.PORT || 3000, '0.0.0.0');
# Flask
app.run(host="0.0.0.0", port=int(os.environ.get("PORT", 5000)))

If you have ports defined in .replit, automatic port detection is turned off. You then need a port entry with externalPort = 80 that maps to the localPort your server actually uses.

2. Secrets didn’t come with you

Replit notes that Secrets set in the Project Editor do not automatically carry over to the published app. Add every API key, database URL and auth secret in the Publishing pane. If you skip this, you get undefined values, failed API calls, database connection errors and broken logins in production only.

3. The homepage is too slow for the health check

Before an app goes live, Replit requests your homepage. If it takes more than five seconds, the health check can time out and publishing fails at the final step. Move slow startup work (migrations, warm-up fetches, large data loads) out of the request path.

4. The program exits

Published apps are expected to keep running. A script that runs once and exits gets restarted over and over. Make sure the run command starts a long-lived web server.

5. Wrong deployment type

Static Deployments serve only HTML, CSS and JS files. If your app has API routes, auth callbacks or server-side database calls, switch to Autoscale in the Publishing pane.

Also check

Check it worked

Open the published URL in a private window, sign in, and run the main flow once end to end. Then add a free uptime monitor so you hear about it the next time it breaks.

Sources

Tools mentioned

Monitoring

Sentry

Error monitoring and tracing. See the stack trace, the browser and the release behind every crash your users hit.

Free: Developer plan: free for one user
Monitoring

UptimeRobot

Pings your site, API or port on a schedule and alerts you when it goes down. Includes a basic public status page.

Free: 50 monitors at a 5-minute interval