QAlaunch

Replit works in dev but not in production: the real causes

When a Replit app works in the preview but breaks once published, the published copy is missing something the development copy has. Usually that is a secret, because development and deployment secrets are separate stores; a DATABASE_URL that still points at the development database; or a hard-coded localhost address. Add the missing values to the deployment secrets, point DATABASE_URL at production, replace localhost with relative paths, and publish again.

Opens your site in a real browser on desktop and phone. Free, about two minutes, no signup. Full report from $19.

What you'll see

The published replit.app site loads but lists are empty, sign-in fails, a payment button does nothing, or every API call errors. The same actions work perfectly in the workspace preview. Sometimes the published site only shows an error page with no detail.

Why it happens

1. A secret exists in development only

Replit keeps development secrets and deployment secrets apart, and changing one does not touch the other. An API key added in the editor’s Secrets pane is undefined in the published app until you add it to the deployment.

2. The database connection points at the wrong place

Replit’s docs say to check DATABASE_URL first when an app works in preview but fails published. If it targets the development database, or the production database has no tables or rows yet, pages render with nothing in them.

3. Hard-coded localhost URLs

Code that calls http://localhost:3000/api or 127.0.0.1 works inside the workspace, where the browser and server share a machine. In the published app the visitor’s browser tries to reach its own computer and the request fails.

4. Auth and payment redirects still list the dev address

OAuth providers, Supabase, Stripe and similar services only redirect to URLs you have allowed. If only the replit.dev address is listed, sign-in and checkout break on replit.app or your domain.

How to fix it

  1. Open the published site, press F12 and reproduce the problem. Note failed requests in the Network tab, especially any going to localhost, and the first red error in the Console.
  2. Open the Publishing pane, find the deployment, and read its logs from the three-dot menu. Look for undefined values, connection errors or missing modules.
  3. Compare the editor Secrets pane with the deployment secrets key by key. Add anything missing to the deployment secrets, then click Publish so the new values reach the live app.
  4. Check DATABASE_URL in the deployment secrets. Make sure it points at the production database and that the production database has its tables and any seed data the app needs.
  5. Search the code for localhost and 127.0.0.1 and replace those calls with relative paths such as /api/items or with a base URL read from an environment variable.
  6. Add the replit.app URL and your custom domain to the allowed redirect URLs in your auth and payment providers.

Prompt to paste into Replit

The published app fails but the preview works. Find every hard-coded localhost or 127.0.0.1 URL and replace it with a relative path or an environment variable. List every secret the app reads, and add a startup check that logs the names (not the values) of any required secrets that are missing, so the deployment logs show it clearly.

How to check it's fixed

  • Walk through the main flows on the published URL with DevTools open: load data, sign in, submit a form. No requests should go to localhost and none should fail.
  • Read the deployment logs after a fresh publish and confirm the startup check reports no missing secrets.

What a QAlaunch scan shows for this

  • Failed network requests from the live page, including calls aimed at localhost or 127.0.0.1.
  • JavaScript console errors on load, such as undefined configuration values.
  • Empty sections or error states where content should appear, visible in the screenshots.
  • It cannot open your deployment secrets or database, so it reports the symptoms a visitor gets rather than the missing value itself.

See exactly what a full report contains in the sample report.

Frequently asked questions

I added the secret but the published app still fails. Why?

Deployment secret changes reach the live app when you publish again. Click Publish after editing them, then retest.

Why is my production database empty?

Development and production databases hold separate data. Publishing deploys your code and schema changes, not the test rows you created while building.

Why does a file the app saved disappear?

The published file system resets on every publish, so uploads or JSON files written to disk are lost. Store them in a database or object storage instead.

Done for you · not automated

Rather have a QA engineer test it by hand?

If this is a site you're launching or handing to a client, I'll go through it by hand, including the Replit-specific issues a scan can't reach, like logged-in flows.

$299one-time · 3 business days
  • Up to 10 key pages tested by hand, not a scan
  • Every flow a customer uses: forms, sign-up, checkout, booking
  • Real mobile and desktop browsers
  • A written report in plain language, with screenshots
  • A 15-minute call to walk you through it
  • 10 years of professional QA experience

Tell me about your site and I'll reply personally, usually the same day.

No payment now. I'll confirm scope and price first.

More for Replit: all Replit fixes · Replit testing

Written by Waqas Ahmad, QA engineer with 10 years of professional testing experience. Last checked October 26, 2026.

Sources: Replit docs: deployment and publishing help · Replit docs: publishing troubleshooting · Replit forum: DATABASE_URL will not get saved for deployment