Replit app broken after deploy or republish: how to fix it
Your app runs fine in the Replit Preview, but the published replit.app URL shows an error, a blank page or "Application failed to respond". Or it worked for weeks and broke after you hit Republish. Preview and the published app are separate environments, so a working Preview proves very little about production. Here is the order to check things in.
1. Check Replit Status first
Before changing any code, look at status.replit.com. If publishing or hosting has an incident, wait for it to clear and republish. Changing code during an outage just adds a second problem.
2. Read the deployment logs, from the top
Open the Publishing pane, find the failed deployment and open its logs (the Logs tab, or the three-dot menu next to the deployment). Scroll up to the first real error, not the final "build failed" or "promotion failed" line. Work out which stage failed:
- Build: missing packages, a wrong build command, a file path that only exists on your machine.
- Startup or health check: the server never starts, exits straight away, or listens on the wrong address or port.
- Serving requests: it goes live but returns 500 or 502. Check the runtime logs at the time of a failing request.
Don't republish an unchanged build over and over. Fix one thing, republish, and compare the new logs.
3. Copy your secrets to the published app
This is the most common cause. Secrets you set in the Project Editor don't automatically carry over to the published app, and the two stores stay separate after that. Add every key your app needs, such as DATABASE_URL, STRIPE_SECRET_KEY, SUPABASE_URL and API keys, in the Publishing pane's secrets, then republish. Changing a secret doesn't update a running deployment until you publish again.
Also check that DATABASE_URL points at your production database, not the development one, and that any pending migrations have been run against production.
4. Listen on 0.0.0.0 and the right port
"Application failed to respond" usually means your server isn't listening where Replit expects. Bind to 0.0.0.0, not localhost or 127.0.0.1, and read the port from the environment:
const PORT = process.env.PORT || 3000;
app.listen(PORT, "0.0.0.0");
port = int(os.environ.get("PORT", 3000))
app.run(host="0.0.0.0", port=port)
If your .replit file has a [[ports]] section, automatic port detection is off. Then you need an entry with externalPort = 80 whose localPort matches the port your server actually uses.
5. Make the health check pass
Before Replit marks a deployment as live, it sends a request to your app. If your homepage takes more than about five seconds to answer, publishing can fail at the last step. Keep startup light, and make sure / returns a quick 200. Watch out for middleware that redirects every request to HTTPS or to a login page: the internal health check may not send the same headers as a real browser, so a blanket redirect can make it fail.
Also make sure your run command starts a long-running server. A command that builds and then exits will keep getting restarted.
6. Remove hard-coded localhost URLs
If the app loads but API calls fail, search your code for localhost:3000 and 127.0.0.1. Use relative paths like /api/... or a URL from an environment variable. While you're at it, update login callback URLs, Stripe webhook URLs and CORS allowlists to your published domain.
7. Republish, then test signed out
Once logs are clean, publish again. Open the published URL in a private window, sign up as a new user, and click through the paths that matter: login, the main page, and payment if you have one. Files written to the local disk at runtime don't persist on published apps, so anything users upload should go to a database or storage service.
Quick checklist
- Replit Status is green
- First error in the deployment logs found and fixed
- Every secret added to the published app, then republished
- Server listens on
0.0.0.0andprocess.env.PORT - Homepage answers with a 200 in under five seconds
- No hard-coded localhost URLs; callbacks and webhooks use the live domain
Want a second pair of eyes?
Mendlark fixes AI-built apps that break at go-live. Start with a free scan and we'll tell you what's wrong and what a fix costs, or get a fix for €49 (launch price, normally €79) and we'll fix it, test it and send it as a pull request. Related: Env variables undefined in production.
Not sure what else is wrong? Paste your app link into the free instant check and get a plain-English list of problems in seconds.