# Replit app works in Preview but breaks when published

> If a Replit app works in Preview but not when published, read the publishing logs, check the production secrets, make the server listen on 0.0.0.0 rather than localhost and keep it running, and make sure the homepage answers the health check quickly. Then connect your domain with the exact DNS records Replit shows.

Canonical: https://shipfast.online/rescue/replit/go-live/
Last updated: 2026-10-25

By [Prayag Dalal](https://shipfast.online/about/). Checked against Replit's documentation on 2026-10-25.

## Symptoms

- Publishing fails, or the published address shows an error while Preview works.
- Sign-in, payments or the database fail only on the published app.
- Your custom domain doesn’t load, or never shows Verified.

## Why it happens

Publishing saves a snapshot of your app and runs it on Replit’s cloud, separately from the Project Editor. Replit’s troubleshooting guide lists the usual differences: production secrets, run and build commands, a program that exits instead of staying up, a server listening on localhost instead of 0.0.0.0, port settings, and a homepage too slow for the health check.

On a custom domain, the other common cause is DNS: records that don’t exactly match what Replit shows, or changes that haven’t spread yet.

## What Replit already handles

- **Publishing tool:** Domain, access, production database, monitoring and security scan in one pane.
- **Logs:** The Logs tab in Publishing shows stack traces, missing packages and startup errors.
- **Monitoring:** Replit can check that the app is online and email you if it goes down.
- **Custom domains:** Add your domain, copy the two DNS records, and HTTPS is set up automatically.

## Fix it yourself

1. **Confirm Preview works.** If Preview is broken, publishing won’t fix it.
2. **Read the publishing logs.** Look for missing packages, missing environment variables and startup errors.
3. **Check production secrets.** Replit’s docs disagree on whether editor secrets carry over, so check the published app’s secrets and use production values.
4. **Listen on 0.0.0.0 and the right port.** Servers listening on localhost or 127.0.0.1 don’t work when published. If ports are set in .replit, set externalPort to 80.
5. **Keep the process running and the homepage fast.** Published apps expect a long-running server, and Replit sends a health check request before it marks the app live.
6. **Then connect the domain.** Add it in Publishing settings, copy the records exactly at your registrar, wait for Verified, and test sign-in and checkout on the new address.

## Where it still goes wrong

- Deployment geography is locked once you publish. Changing region later means remixing the app.
- On Autoscale, cost grows with traffic. Check the cost at maximum traffic in the machine configuration.
- Third-party settings such as sign-in redirect URLs or Stripe details may still point at the replit.app address.

## FAQ

### Why does my Replit app work in Preview but not after publishing?

Most often: missing production secrets, a server listening on localhost instead of 0.0.0.0, wrong run or build commands, or a slow homepage failing the health check. The Logs tab usually shows which.

### How long does a custom domain take on Replit?

DNS changes can take from a few minutes to a few hours. Replit shows Verified once it sees the records.

### Which deployment type should I choose?

Replit recommends Autoscale for most apps, because it scales from zero with demand.

## Sources

- [Replit docs: Troubleshoot publishing](https://docs.replit.com/build/troubleshooting)
- [Replit docs: Publishing](https://docs.replit.com/features/publishing/overview)
- [Replit docs: Add a custom domain](https://docs.replit.com/build/add-custom-domain)

## Get it fixed

App rescue, From $1,000, fixed price: [send your app](https://shipfast.online/contact/?service=app-rescue).

## Related

- [All Replit guides](https://shipfast.online/rescue/)
- [Free production readiness check](https://shipfast.online/tools/production-readiness-check/)
