The biggest mistake developers make when deploying on Replit is assuming production behaves like the workspace.
In the interactive workspace, Replit feels comfortably stateful. You write code, test an API call, generate a local SQLite database, and upload test images directly into your project root. Everything stays right where you left it. Then, you click "Publish", push your application to a live deployment, and within days—or after the first automated redeploy—customer records vanish and uploaded files disappear into thin air.
At 365Finds, we have tracked how teams transition from rapid prototyping to production on Replit. The platform's deployment engine is not a persistent virtual server; it is a containerized, cloud-native runtime built on Google Cloud Platform. To run production applications reliably, you have to treat Replit deployments as strictly stateless compute. Here is how to configure environment secrets, persistent databases, object storage, and custom domains without getting burned.
1. Secrets Management: Isolating Dev and Production
Hardcoding credentials or committing .env files into code repositories is dangerous, especially in collaborative environments. Replit provides a dedicated Secrets tool built on top of Google Cloud Secret Manager, encrypting values at rest with AES-256 and injecting them into memory at runtime.
Workspace Secrets vs. Deployment Secrets
A frequent point of confusion is how secrets propagate. When developing inside the workspace, you use the Secrets pane (the lock icon in the sidebar). However, production deployments require deliberate credential isolation:
- Workspace Secrets: Intended for development and local testing. Use sandbox Stripe keys, test database connections, and test OAuth credentials here.
- Deployment Secrets: Configured under the Publishing / Deployments settings. These override or supplement workspace values specifically when your app runs as a live deployment.
When you trigger a deployment, Replit packages a snapshot of your project and applies the Deployment Secrets. If you update a production secret later, the change does not take effect dynamically in memory; you must republish the deployment to roll out the new environment configuration.
Accessing Secrets in Application Code
Secrets are exposed directly as standard system environment variables. You do not need proprietary SDKs to read them:
- Node.js / TypeScript:
const apiKey = process.env.STRIPE_SECRET_KEY; const isProduction = process.env.REPLIT_DEPLOYMENT === '1'; - Python:
import os api_key = os.environ.get("STRIPE_SECRET_KEY") is_production = os.environ.get("REPLIT_DEPLOYMENT") == "1"
Notice REPLIT_DEPLOYMENT. Replit automatically sets this variable to '1' in live deployments. At 365Finds, we strongly recommend using this flag to enforce runtime assertions—preventing your application from booting if production keys are accidentally pointing to staging resources.
Note on Static Deployments: If you choose Replit's Static Deployment option (for plain HTML/JS or static site builds), secrets are deliberately disabled. Client-side browser code cannot safely consume server-side secrets. If your frontend requires backend APIs, deploy an Autoscale or Reserved VM backend and keep keys server-side.
2. Persistent Storage: The Ephemeral Filesystem Trap
In Replit Deployments, the container filesystem is ephemeral. Any file written to the local disk during runtime will be wiped clean when the container scales down, restarts, crashes, or receives a new build rollout.
+-------------------------------------------------------------------+
| Replit Architecture |
| |
| Workspace (Stateful IDE) Deployment (Stateless Run) |
| +-----------------------+ +--------------------------+ |
| | Persistent Workspace | | Ephemeral Container Disk | |
| | Disk (Code & Edits) | | (Wiped on redeploy) | |
| +-----------+-----------+ +------------+-------------+ |
| | | |
| | Publish Snapshot | |
| +--------------------------------->+ |
| | |
| +---------------------------+ |
| | | |
| v v |
| Replit Managed DB App Storage (GCS) |
| (PostgreSQL State) (Persistent Files) |
+-------------------------------------------------------------------+
If your application writes user avatars to ./uploads or stores transactional data in ./database.db via SQLite, you will lose data. Production persistence requires separating relational state from unstructured asset storage.
Relational State: Replit Managed PostgreSQL
For structured records, users, and relational schemas, use Replit's native PostgreSQL database service:
- Automatic Environment Separation: Replit automatically maintains a development database in your workspace and provisions an isolated production database upon publishing.
- Connection Injection: Replit injects the production connection string into the deployment container as the
DATABASE_URLenvironment variable. - ORM Compatibility: Standard ORMs like Prisma, Drizzle, or SQLAlchemy connect out of the box using
process.env.DATABASE_URLoros.environ["DATABASE_URL"].
Always run schema migrations as part of your deployment build command (e.g., npx prisma migrate deploy or drizzle-kit migrate), ensuring your production schema syncs before incoming traffic hits the container.
Unstructured Assets: Replit App Storage (Object Storage)
For binary files, user uploads, exports, and images, Replit provides App Storage, backed by Google Cloud Storage (GCS) buckets:
- Assets are stored externally in durable object buckets, completely decoupled from the container lifecycle.
- In Node.js, install
@replit/object-storageto interact with buckets:import { Client } from '@replit/object-storage'; const storage = new Client(); // Save an uploaded buffer await storage.uploadFromBytes('avatars/user-123.png', fileBuffer); // Download an asset const { ok, value } = await storage.downloadAsBytes('avatars/user-123.png'); - In Python, use the native
replit.object_storagemodule.
365Finds recommends App Storage over self-managed AWS S3 buckets for early-to-mid stage projects on Replit, simply because authentication and credential rotation are handled automatically by Replit's runtime without needing manual IAM key management.
3. Custom Domains and DNS Configuration
Every Replit deployment receives an assigned default URL formatted as <your-app>.<cluster>.replit.app. For professional applications, you will want a custom domain.
Linking an External Registrar Domain
You can purchase domains directly in Replit, or connect a domain purchased via third-party registrars (Cloudflare, Namecheap, GoDaddy, Porkbun):
- Go to your deployment view, open Publishing, and select Domains -> Connect your own domain.
- Enter your custom domain (e.g.,
app.yourdomain.comor apexyourdomain.com). - Replit will generate two DNS records that you must add to your DNS provider's dashboard:
- A Record: Points your host name to Replit's ingress IP address.
- TXT Record: A verification string required for domain ownership validation and SSL provisioning.
Critical DNS Rules and Gotchas
At 365Finds, we regularly see two DNS pitfalls cause deployment failures:
| Configuration Area | Requirement | Common Failure Mode |
|---|---|---|
| Apex / Root Domain | Must use an A Record pointing to Replit's IP. | Attempting to use a CNAME record on a root domain; RFC specifications and many DNS providers reject apex CNAMEs. |
| Cloudflare Proxy | DNS record proxy status must be set to DNS Only (grey cloud). | Keeping Cloudflare proxy active (orange cloud) blocks Replit's Let's Encrypt automated challenge, preventing SSL issuance. |
| Subdomains | Must configure each subdomain (app.example.com, www.example.com) individually. | Expecting wildcard certificates (*.example.com); Replit does not support wildcard SSL certificates. |
Once records are added, return to Replit and click Verify. DNS propagation typically takes between 5 to 30 minutes, though registrar delays can extend up to 48 hours. Replit automatically issues and maintains TLS/SSL certificates via Let's Encrypt without manual certificate renewals.
4. Architectural Choice: Autoscale vs. Reserved VM
Replit provides multiple deployment execution models. Selecting the wrong model undermines your storage and lifecycle assumptions:
- Autoscale: Ideal for standard web applications, REST APIs, and webhook consumers. Containers scale down to zero when idle, saving compute budgets. However, cold starts occur upon new requests, and any in-memory state is flushed.
- Reserved VM: Ideal for long-lived processes, WebSockets, background queue workers, and Discord/Telegram bots. Containers run continuously 24/7 without scaling to zero.
365Finds prefers Autoscale paired with Replit Managed PostgreSQL and App Storage for transactional web apps, as it delivers high cost-efficiency. If your app relies on persistent WebSocket connections or continuous cron schedules, choose Reserved VM.
Deploying production software on Replit succeeds when you abandon the illusion of a monolithic server and embrace stateless cloud containers. Configure your secrets in the Deployment panel, redirect every state write to PostgreSQL or App Storage, set your Cloudflare records to DNS-only, and verify that REPLIT_DEPLOYMENT === '1' before accepting customer traffic.