AD SPACE AVAILABLE · BRAND PARTNERS WELCOME

How Replit Deployments Handle Persistent Databases and Custom Domains

최지향 · 365Finds Editorial
Indexed 88,650 Wiki articles

Put 365 Wiki to work with your AI

Copy the prompt below, paste it into the AI you already use, then ask your question.

Download full Skill

Try it with the prompt first. If you use 365 Wiki often, install the full 365Wiki Skill so you do not have to paste it again. No regular AI? Gemini or Microsoft Copilot on the web will work.

365Wiki Skill

Going from an interactive prompt in Replit to a live, production web application feels deceptively instantaneous. You click "Publish", pick a target, and a public URL appears. Yet under the hood, the transition between an in-browser development environment and an internet-facing deployment is where many developers get burned. At 365Finds, we have tracked numerous teams who assumed that a database file or an uploaded image written to their Repl's local directory would stay intact in production. It does not.

To run production workloads reliably on Replit Deployments, you must understand two operational pillars: how persistence actually functions when containers spin down, and how to route custom domain traffic through Replit's ingress without breaking TLS verification.

+-------------------------------------------------------------+
|                      Replit Workspace                       |
|   - Interactive Editor & Replit Agent                       |
|   - Ephemeral/Sandboxed Workspace Filesystem                |
|   - Development Database (Helium / Dev Postgres)            |
+-------------------------------------------------------------+
                               |
                        [ Publish / Deploy ]
                               |
                               v
+-------------------------------------------------------------+
|                     Replit Deployments                      |
|                                                             |
|   +-----------------------+     +-----------------------+   |
|   |  Deployment Targets   |     |    Persistent Data    |   |
|   |  - Autoscale (0 to N) | --> |  - Production Postgres|   |
|   |  - Reserved VM        |     |    (Isolated Instance)|   |
|   |  - Static / Scheduled |     |  - App Object Storage |   |
|   +-----------------------+     +-----------------------+   |
|                                                             |
|   +-----------------------------------------------------+   |
|   |                   Routing & Domains                 |   |
|   |   - Default: <app-name>.replit.app                  |   |
|   |   - Custom: Apex (A + TXT) / Subdomain (CNAME / A)  |   |
|   |   - Automated Let's Encrypt TLS (DNS-Only Mode)     |   |
|   +-----------------------------------------------------+   |
+-------------------------------------------------------------+

The Storage Trap: Ephemeral Disks vs. Managed Postgres

The most dangerous misconception in Replit is treating the project workspace as a persistent server disk. In the development editor, your files, SQLite databases, and uploaded assets look stable. But Replit Deployments—especially Autoscale, which Replit sets as default for dynamic web apps—operate on isolated, containerized snapshots running on Google Cloud Platform infrastructure.

When you publish an Autoscale deployment:

At 365Finds, our stance is uncompromising: never deploy a stateful web application on Replit using SQLite or local filesystem writes.

The Dual-Database Model (Development vs. Production)

Replit solves persistence by decoupling compute from state through managed, serverless PostgreSQL. What we appreciate about Replit's architecture is its strict isolation between environments:

Feature DimensionDevelopment DatabaseProduction Database
Primary RoleRapid iteration, testing, and AI Agent schema experimentsLive customer transactions and real application records
Agent AccessFull read/write; Replit Agent can modify tables and inject mock rowsProtected; AI Agent can inspect read replicas for schema context but cannot alter live records
Connection StringInjected via local workspace DATABASE_URLAutomatically mapped to production DATABASE_URL upon publishing
Schema SyncHandled directly by code or ORM migrationsReplit calculates diffs (via drizzle-kit) and requires approval prior to deployment
Cost StructureIncluded with Replit workspace compute tiersBilled on active compute hours and allocated storage volume

When Replit Agent creates an application, it provisions a local development Postgres instance and defines models using an ORM like Drizzle. When you press "Publish", Replit generates SQL migration diffs. If the migration detects ambiguous changes—such as dropping a column versus renaming one—the publishing panel prompts you to verify the migration before applying it to the production database.

For unstructured files such as PDFs and user avatars, Replit Deployments provide App Storage (object storage buckets). Alternatively, you can connect external S3-compatible object buckets using Replit Secrets.

Using External Databases

You are not locked into Replit's built-in Postgres. Because Replit injects database connectivity via standard environment variables, you can swap the managed database for external providers like Neon, Supabase, PlanetScale, or AWS RDS. You simply enter your connection string into the Secrets tool under DATABASE_URL. Replit Deployments pass these secrets into the production runtime container as encrypted environment variables.


Configuring Custom Domains on Replit Deployments

By default, every published deployment is assigned a public URL under <your-app>.replit.app with pre-installed TLS. Replacing that subdomain with your own brand domain (such as www.example.com or an apex domain example.com) is configured directly inside the Publishing -> Domains dashboard.

Replit supports two onboarding paths: purchasing directly through Replit, or pointing an external domain registered at providers like Cloudflare, Namecheap, or GoDaddy.

Custom Domain Ingress Pipeline:

[ Browser Client ]
        |
        v  (HTTPS / Port 443)
[ DNS Provider (Cloudflare / Namecheap) ]
        |  - Root Domain: A Record -> Replit Ingress IP
        |  - Ownership Check: TXT Record -> Verification Hash
        v
[ Replit Edge Proxy & Let's Encrypt ACME ]
        |  - Automatic Certificate Provisioning & Renewal
        v
[ Replit Deployment Container (Autoscale / Reserved VM) ]

External DNS Configuration Requirements

When mapping a third-party domain to a Replit Deployment, you must configure two distinct DNS records at your registrar:

  1. A Record (Routing Traffic): For an apex domain (example.com), point the @ host directly to the dedicated IPv4 address provided in your Replit deployment settings. Replit's edge routing does not support apex CNAME records. For subdomains (app.example.com), configure an A record or a CNAME pointing to the deployment ingress target.
  2. TXT Record (Ownership Verification & SSL Issuance): Replit generates a unique cryptographic token that must be placed in a TXT record. Replit's automated certificate system will not issue a Let's Encrypt SSL/TLS certificate until this verification record resolves.

The Cloudflare Proxy Pitfall

The single most common mistake 365Finds observes among developers configuring Replit domains involves Cloudflare.

When you add Replit's A record into Cloudflare, Cloudflare defaults to enabling its orange-cloud proxy (Proxied). This creates an immediate failure mode:

To fix this, you must toggle the Cloudflare proxy status to DNS Only (Gray Cloud). Leave it on DNS Only until Replit validates the TXT record and successfully provisions the SSL certificate.

Furthermore, if your registrar has existing IPv6 (AAAA) records attached to that hostname, you must delete them. Replit Deployments operate primarily over IPv4 edge ingress; residual AAAA records pointing elsewhere will derail SSL issuance and cause intermittent connection timeouts.


Deployment Strategy: Autoscale vs. Reserved VM

Choosing how your persistent database and domain behave also depends on your deployment tier:

Replit does not support wildcard SSL certificates (*.example.com). Every custom subdomain must be individually bound inside the Publishing tool, and DNS verification must run for each specific hostname.

References