Beginners make one recurring mistake when they start building on Replit. They click the green "Run" button, look at the built-in webview showing their React frontend and Express or FastAPI backend, copy the development URL, and text it to a friend.
Ten minutes later, the friend messages back: the site is dead.
At 365Finds, we see this all the time. The workspace preview is not a deployment. It is an ephemeral development container that falls asleep the instant you close the browser tab or step away for lunch. If you want a real, persistent full-stack application that handles user logins, persists database records, and stays online 24/7, you have to transition from the interactive editor to Replit's production deployment pipeline.
Here is 365Finds' unvarnished guide to how Replit hosting actually works, how to configure your full-stack app without crashing the server, and where the platform's hidden traps lie.
The Core Concept: Workspace vs. Deployed Snapshot
When you code in Replit, you are working inside an interactive development environment. When you deploy—what Replit calls "Publishing"—Replit does something completely different:
- It takes an immutable snapshot of your codebase.
- It packages that snapshot into an isolated, single-tenant container hosted on Google Cloud Platform (GCP).
- It assigns a permanent production URL (ending in
.replit.appor your custom domain). - It decouples production runtime from your workspace.
This decoupling is critical. If you modify your code in the Replit editor tomorrow, your live website does not change until you manually click "Update" or "Publish" again. That is a safeguard against breaking production while experimenting, but it confuses newcomers who fix a bug and wonder why their live URL still throws an error.
Step 1: Choose the Right Deployment Type (Pick Autoscale)
Open the Publishing tool from the left sidebar or the "Publish" button in the top-right corner. Replit presents four deployment options:
- Autoscale (Default): Best for full-stack apps. Runs dynamic server instances that scale down to zero when idle and boot instantly on incoming web requests.
- Reserved VM: Best for persistent background processes, Telegram bots, or long-lived WebSockets. It stays on 24/7 on dedicated compute at a fixed monthly cost ($15 to $35+/month).
- Static: Only serves static HTML, CSS, and client-side JavaScript. Do not choose this for full-stack applications. A backend server (Node.js, Python, Go) will not run here.
- Scheduled: Cron jobs that run periodically and exit.
For 95% of beginner full-stack projects, 365Finds explicitly recommends Autoscale.
Why? Because Autoscale costs a $2/month base fee plus metered compute units ($0.60 per million units) only while serving live requests. If your portfolio app or SaaS prototype gets 200 hits a day, your monthly bill is negligible. Paying for a Reserved VM before you have paying customers is throwing cash into a cloud furnace.
Step 2: Configure the .replit Build and Run Directives
Full-stack applications combine two distinct worlds: frontend asset compilation (Vite, Next.js, Webpack) and backend server execution (Express, FastAPI, Django, Flask).
In development, Replit runs both concurrently in watch mode. In production, you must explicitly separate the build stage from the run stage.
Replit configures this through the hidden .replit configuration file in your project root, or via the "Advanced Settings" dropdown inside the Publishing interface. Your .replit file needs a clear [deployment] block:
[deployment]
build = "npm run build"
run = "node dist/server.js"
For Python apps serving a precompiled frontend:
[deployment]
build = "npm run build"
run = "python main.py"
The Port Binding Trap
Here is the bug that kills beginner deployments more than any other: hardcoding your server to localhost or port 3000.
In production, Replit's ingress proxy routes incoming external traffic to your container. If your server binds strictly to 127.0.0.1, the health check fails and Replit aborts the deployment.
Always bind your server to 0.0.0.0 and listen to Replit's assigned port via environment variables:
// Node.js Express example
const port = process.env.PORT || 3000;
app.listen(port, "0.0.0.0", () => {
console.log(`Server listening on port ${port}`);
});
# Python FastAPI / Uvicorn example
import os
import uvicorn
if __name__ == "__main__":
port = int(os.environ.get("PORT", 8080))
uvicorn.run("main:app", host="0.0.0.0", port=port)
Step 3: Wire Up Secrets and Managed PostgreSQL
Beginners frequently commit .env files with sensitive database credentials or OpenAI API keys directly to their public project files. On Replit, this is unnecessary and dangerous.
Using the Secrets Tool
Replit provides a native Secrets tool (the padlock icon in the left panel). Environment variables entered here are encrypted and injected into your app's environment at runtime without touching public source control.
Make sure your production API keys exist in the Secrets panel before deploying.
Connecting to Production PostgreSQL
If your full-stack app needs a relational database, do not try to run an embedded SQLite file in Autoscale mode. When Autoscale containers spin down or redeploy, local file writes are ephemeral and will be wiped.
Instead, use Replit's built-in managed PostgreSQL (powered by Neon):
- Open the Database tool in your workspace.
- Replit automatically provisions a PostgreSQL database and injects the
DATABASE_URLconnection string directly into your app's environment. - In your database client or ORM (such as Prisma, Drizzle, or SQLAlchemy), read
process.env.DATABASE_URL. - Crucially: Replit separates the development database from the production database. In the Database settings, ensure your migrations or schema sync run on the production database before launch.
The production database automatically suspends after 5 minutes of complete inactivity ($0.16/hour when active, $0.35/GiB storage per month), aligning perfectly with Autoscale economics.
Step 4: Publish, Set Guardrails, and Monitor
With build scripts tested, secrets stored, and database configured, go back to the Publishing panel:
- Set Machine Power: By default, Replit assigns a modest machine configuration (such as 0.5 vCPU and 1 GiB RAM). For small apps, this is plenty. Do not inflate this until performance benchmarks prove a bottleneck.
- Set Max Machines: This is 365Finds' strongest operational rule for beginners. Cap your maximum autoscale instances at 2 or 3. If a bot scrapes your site or your frontend triggers an infinite fetch loop, this cap protects you from an unexpected credit charge.
- Click "Publish": Replit initiates container provisioning, runs your
buildcommand, tests port connectivity, and marks the deployment live.
Once active, Replit generates your live production link: https://<your-project-name>.<your-username>.replit.app.
Step 5: Connecting a Custom Domain
A .replit.app domain is acceptable for staging, but professional apps require custom branding. You have two paths in Replit:
- Direct In-App Purchase: Navigate to Tools > Domains. You can purchase domains directly with automated DNS setup and SSL provisioning handled behind the scenes.
- External Registrar (Cloudflare, Namecheap, GoDaddy): In your Publishing settings, enter your external domain name. Replit will output specific A and TXT DNS records. Log into your registrar's DNS panel, add those records, and wait for DNS propagation. Replit automatically issues a free Let's Encrypt SSL certificate once verification succeeds.
What 365Finds Thinks: The Honest Trade-Off
At 365Finds, we appreciate Replit's deployment model for what it is: the fastest path for a beginner to get a full-stack web application onto real, secure cloud infrastructure without learning Terraform, writing Dockerfiles, or configuring AWS security groups.
However, we need to talk about cold starts.
Because Autoscale scales to zero after 15 minutes of inactivity, the first visitor who opens your dormant app will trigger a cold start. The container has to spin up, the Node or Python runtime must initialize, and the sleeping PostgreSQL database must wake up.
Expect a 3 to 8-second delay on that initial request.
We see beginners frantically checking their server logs, assuming their code crashed. It didn't; the cloud is simply waking up. If you are building a client presentation or an e-commerce checkout where an 8-second delay is unacceptable, you will have to pay the premium for a Reserved VM ($15+/month) to keep instances permanently warm.
For learning, early-stage MVPs, and internal tools, however, the Autoscale setup offers an unbeatable mix of convenience and cost containment.
Troubleshooting Checklist
| Symptom | Cause | Solution |
|---|---|---|
| Deployment stuck on "Building" | Build script never exits or hangs | Check .replit [deployment] build; ensure it does not run dev watch servers. |
| Health check failed / 502 Bad Gateway | App bound to 127.0.0.1 instead of 0.0.0.0 | Bind server listener to 0.0.0.0 and process.env.PORT. |
| Database data resets after idle | Using local SQLite or JSON file | Switch to Replit Managed PostgreSQL via DATABASE_URL. |
| Secrets undefined in production | Secrets set in local shell instead of Secrets tool | Enter environment keys in the official Replit Secrets panel. |
| New code changes not visible live | Forgot to republish snapshot | Open Publishing menu and click "Update" or "Publish". |
Replit checks port availability within a 60-second timeout window during deployment; if your server process fails to open an active listening socket before that timer expires, the deployment rollback triggers automatically.