Skip to main content
RapidDev - Software Development Agency
replit-tutorial

How to set up continuous deployment in Replit

Replit supports continuous deployment through its GitHub integration and Autoscale or Reserved VM deployment types. You connect your Repl to a GitHub repository, configure build and deployment commands in the .replit file, and set up a workflow where pushing to the main branch triggers a redeployment. This tutorial covers the full pipeline from GitHub connection to production rollback strategies.

What you'll learn

  • Connect a Replit App to GitHub for two-way code synchronization
  • Configure .replit build and deployment commands for production
  • Set up deployment Secrets separately from workspace Secrets
  • Roll back to a previous working version when a deployment fails
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Advanced9 min read30-45 minutesReplit Core ($25/mo) or Pro ($100/mo) plans. Requires a GitHub account. Works with Node.js, Python, and any framework supported by Replit.March 2026RapidDev Engineering Team
TL;DR

Replit supports continuous deployment through its GitHub integration and Autoscale or Reserved VM deployment types. You connect your Repl to a GitHub repository, configure build and deployment commands in the .replit file, and set up a workflow where pushing to the main branch triggers a redeployment. This tutorial covers the full pipeline from GitHub connection to production rollback strategies.

Build a GitHub-to-Replit Continuous Deployment Pipeline

This tutorial teaches you how to set up a continuous deployment pipeline where code changes pushed to GitHub automatically update your live Replit application. You will connect a Replit App to a GitHub repository, configure build and deploy commands, set up environment variables for production, and establish a rollback strategy using Replit's version history. This is an advanced workflow aimed at developers who want professional deployment practices without managing external CI/CD infrastructure.

Prerequisites

  • A Replit account on the Core ($25/mo) or Pro ($100/mo) plan
  • A GitHub account with repository creation permissions
  • A working full-stack application in Replit (frontend and backend)
  • Familiarity with Git basics (commit, push, pull)
  • All API keys and database credentials stored in Tools → Secrets

Step-by-step guide

1

Connect your Replit App to GitHub

Open the Tools dock on the left sidebar and click Git. If your Repl does not have a Git repository initialized, Replit will prompt you to create one. Click the Connect to GitHub button and authorize Replit to access your GitHub account if you have not done so before. Select Create a new repository or choose an existing empty repository. Replit will push your current code to the main branch. Once connected, changes sync bidirectionally — edits in Replit push to GitHub, and pushes to GitHub pull into Replit.

Expected result: The Git pane shows your GitHub repository URL and the latest commit. Your code appears on GitHub under the main branch.

2

Configure the .replit deployment section

Open the .replit file (enable Show hidden files in the file tree menu) and configure the deployment section. The build command runs once during deployment setup — use it for dependency installation and compilation. The run command starts your production server. Set deploymentTarget to cloudrun for Autoscale deployments. Make sure your server binds to 0.0.0.0 (not localhost) and that you configure the ports section with externalPort 80, which is required for the health check to pass.

typescript
1# .replit
2entrypoint = "index.js"
3
4run = "npm run dev"
5
6[deployment]
7build = ["sh", "-c", "npm install && npm run build"]
8run = ["sh", "-c", "npm start"]
9deploymentTarget = "cloudrun"
10
11[[ports]]
12localPort = 3000
13externalPort = 80

Expected result: The .replit file contains a valid deployment configuration. The deployment commands are separate from the workspace run command.

3

Ensure your server binds to 0.0.0.0

Replit's deployment health check requires your server to listen on 0.0.0.0 with the external port mapped to 80. This is the single most common deployment failure. Open your server file and verify the host binding. Express apps must pass '0.0.0.0' as the hostname. Flask apps need host='0.0.0.0'. Frameworks like Next.js handle this automatically, but custom servers often default to localhost which is invisible to the health checker.

typescript
1// Express.js — correct binding:
2const PORT = process.env.PORT || 3000;
3app.listen(PORT, '0.0.0.0', () => {
4 console.log(`Server running on port ${PORT}`);
5});
6
7# Flask correct binding:
8if __name__ == '__main__':
9 app.run(host='0.0.0.0', port=3000)
10
11# FastAPI with uvicorn:
12import uvicorn
13if __name__ == '__main__':
14 uvicorn.run('main:app', host='0.0.0.0', port=3000)

Expected result: Your server starts and listens on 0.0.0.0. The health check passes within 5 seconds of startup.

4

Add Secrets to the deployment configuration

Workspace Secrets do not automatically transfer to deployments. Click the Deployments tab, then go to the deployment settings. Find the Secrets or environment variables section and add every key your production app requires: database URLs, API keys, authentication secrets, and any third-party service credentials. This is the number one cause of 'works in development, fails in production' issues on Replit. If you miss a Secret, your app will crash with undefined environment variable errors.

Expected result: All production Secrets are listed in the deployment configuration. The deployment can access every environment variable your app needs.

5

Deploy your application

Click the Deployments tab and select your deployment type. Choose Autoscale for web apps with variable traffic (scales to zero when idle, $1/month base), or Reserved VM for apps that need to run continuously ($10-20+/month). Review the build and run commands, verify Secrets are configured, and click Deploy. The build phase installs dependencies and compiles your app. The run phase starts your server. Monitor the Logs tab for errors during both phases. The deployment typically takes 30-60 seconds.

Expected result: The deployment status changes to Active. Your app is live at the .replit.app URL shown in the Deployments tab.

6

Set up the GitHub-to-Replit deployment workflow

With GitHub connected, your continuous deployment workflow is: make changes locally or in another editor, push to the main branch on GitHub, then open the Replit Deployments tab and click Redeploy to publish the changes. Replit automatically pulls the latest code from GitHub when you open the workspace. For fully automated redeployment, you can create a GitHub Action that calls the Replit deployment API or use a webhook to trigger redeployment on push. The manual redeploy button is the most reliable method as of March 2026.

Expected result: Pushing code to GitHub and redeploying in Replit updates your live application with the latest changes.

7

Set up a rollback strategy

When a deployment fails or introduces a bug, you need to revert quickly. Replit provides version history that lets you restore your workspace to a previous state. Additionally, if you are using Agent, checkpoints are created at each step and can be rolled back to. For Git-based rollback, revert the problematic commit on GitHub, pull the revert into Replit, and redeploy. Always keep your last known-good deployment as a reference point by tagging releases in Git.

typescript
1# In Replit Shell revert the last commit:
2git revert HEAD --no-edit
3git push origin main
4
5# Then redeploy from the Deployments tab

Expected result: After reverting the commit and redeploying, your application returns to the previous working version.

Complete working example

.replit
1# .replit Full-stack deployment configuration
2# This file configures both the development workspace and production deployment
3
4entrypoint = "index.js"
5modules = ["nodejs-20:v8-20230920-bd784b9"]
6
7# Development run command (used when pressing Run button)
8run = "npm run dev"
9
10# Boot command runs when the workspace starts
11onBoot = "npm install"
12
13[nix]
14channel = "stable-24_05"
15packages = ["nodejs-20_x"]
16
17# Deployment configuration
18[deployment]
19# Build runs once during deployment setup
20build = ["sh", "-c", "npm install && npm audit --audit-level=high && npm run build"]
21# Run starts the production server
22run = ["sh", "-c", "NODE_ENV=production npm start"]
23deploymentTarget = "cloudrun"
24
25# Port mapping externalPort 80 is required for health check
26[[ports]]
27localPort = 3000
28externalPort = 80
29
30# Hide non-essential files from the file tree
31hidden = [".config", "node_modules", "package-lock.json", ".git"]
32
33# Environment variables for the run command
34[run.env]
35NODE_ENV = "development"

Common mistakes when setting up continuous deployment in Replit

Why it's a problem: Server binds to localhost instead of 0.0.0.0, causing 'open port was not detected' error

How to avoid: Change app.listen(PORT) to app.listen(PORT, '0.0.0.0') in your server file. This makes the server accessible to the deployment health checker.

Why it's a problem: Forgetting to add Secrets to the deployment configuration after adding them to the workspace

How to avoid: Go to Deployments → Settings → Secrets and re-add every environment variable. Workspace and deployment Secrets are completely separate.

Why it's a problem: Using the development run command for deployment instead of a production start command

How to avoid: The [deployment] run command should use 'npm start' or 'node index.js' for production, not 'npm run dev' which enables hot reloading and debug features.

Why it's a problem: Renaming or moving the GitHub repository after connecting it to Replit

How to avoid: Never rename, move, or delete the connected repository. This breaks the sync permanently. Create a new repository and reconnect if needed.

Why it's a problem: Not setting externalPort to 80 in the [[ports]] section

How to avoid: Add [[ports]] with localPort matching your server port and externalPort = 80. The health check expects the app on external port 80.

Best practices

  • Always bind your server to 0.0.0.0 — not localhost or 127.0.0.1 — for deployment health checks to pass
  • Add Secrets to both the workspace and the deployment configuration since they are managed separately
  • Include npm audit --audit-level=high in your build command to block deployments with known vulnerabilities
  • Tag releases in Git before deploying so you can quickly revert to a known-good version
  • Use Autoscale deployments for web apps with variable traffic to minimize costs during low-traffic periods
  • Test your build and run commands locally in the Shell before deploying to catch configuration errors early
  • Set NODE_ENV=production in your deployment run command to enable production optimizations
  • Monitor the Logs tab after every deployment to catch runtime errors that did not surface during build

Still stuck?

Copy one of these prompts to get a personalized, step-by-step explanation.

ChatGPT Prompt

I have a full-stack Node.js app on Replit connected to GitHub. How do I set up continuous deployment so that pushing to the main branch updates my live app? I need the .replit deployment configuration, health check setup, and a rollback strategy.

Replit Prompt

Set up this project for production deployment. Configure the .replit file with a build command that runs npm install and npm run build, a run command that starts the server on 0.0.0.0:3000, and port mapping with externalPort 80. Make sure the server binds to 0.0.0.0.

Frequently asked questions

Not fully automatically as of March 2026. When you push to GitHub and open the Replit workspace, the code syncs automatically. However, you need to manually click Redeploy in the Deployments tab to publish the changes to production.

The error 'hostingpid1: an open port was not detected' is by far the most common. It happens when your server binds to localhost instead of 0.0.0.0, the port mapping is wrong, or the server takes more than 5 seconds to start.

Use git revert HEAD --no-edit in the Shell to undo the last commit, push to GitHub, and redeploy. Alternatively, use Replit's version history to restore the workspace to a previous state. Agent checkpoints can also be rolled back to.

Autoscale scales to zero when idle (saving money) but has 10-30 second cold starts. Reserved VM is always on with predictable monthly cost. Use Autoscale for web apps with variable traffic; use Reserved VM for WebSocket connections, background jobs, or latency-sensitive applications.

Yes. After deploying, go to Deployments → Settings → Link a domain. Enter your domain, copy the A records and TXT records Replit provides, and add them to your domain registrar's DNS settings. TLS certificates are provided automatically.

The three most common causes are: (1) Secrets not added to the deployment configuration, (2) the server binding to localhost instead of 0.0.0.0, and (3) using REPLIT_DEV_DOMAIN which only exists in the workspace, not in deployments.

Autoscale deployments cost $1/month base plus compute usage. Reserved VMs start at approximately $10-20/month. Build time is billed as compute. A typical small web app costs $1-5/month on Autoscale with moderate traffic.

For enterprise-grade CI/CD with automated testing, staging environments, and multi-service orchestration, the RapidDev engineering team can design a pipeline that integrates Replit with external CI tools for production-ready deployment workflows.

RapidDev

Talk to an Expert

Our team has built 600+ apps. Get personalized help with your project.

Book a free consultation

Need help with your project?

Our experts have built 600+ apps and can accelerate your development. Book a free consultation — no strings attached.

Book a free consultation

We put the rapid in RapidDev

Need a dedicated strategic tech and growth partner? Discover what RapidDev can do for your business! Book a call with our team to schedule a free, no-obligation consultation. We'll discuss your project and provide a custom quote at no cost.