How to Deploy a Replit App to Your Own Server
Deploy your Replit app to a VPS: GitHub export, SSH, PM2, Nginx reverse proxy, HTTPS. Includes cost comparison and when to use Ship instead.
- Export your Replit project to GitHub and test it locally with all environment variables before touching production
- Clone your code on a Linux VPS (DigitalOcean at $5/mo or Hetzner at EUR 2.99/mo), install dependencies, and set up environment variables manually
- Use PM2 or Systemd to keep your app running in the background, and Nginx to reverse-proxy traffic from port 80/443 to your app's internal port
- DIY hosting wins on cost but loses on time; Ship managed hosting wins on peace of mind and flat pricing
- HTTPS requires one command (Certbot) which auto-renews your SSL certificate every 90 days
After you export your code from Replit, the next step is moving it to infrastructure you control. Deploying to your own server means your app runs on compute you own, outside Replit's walled garden. This tutorial walks you through the entire process, from GitHub to live production.
Before You Deploy: Export & Test Locally
You cannot deploy what you have not verified. Before touching a VPS, run your app on your local machine exactly as it will run in production. Export your Replit project to GitHub, clone it locally, and start it the same way you will on the server. This step catches 80 percent of deployment failures before they cost you production downtime.
Get a fresh terminal on your machine. Navigate to your project directory. Install dependencies: npm install for Node, pip install -r requirements.txt for Python, bundle install for Ruby. Start your app: npm start, python app.py, bundle exec rails server. Hit localhost:3000 (or whatever port your app uses). Do not proceed until this works perfectly.
While running locally, verify two critical things. First, create an .env file and manually add every secret your app needs: database URLs, API keys, encryption secrets. Test each one. Second, back up your database if you are using Replit App Storage. Export it as JSON or SQL. You will need this data on the new server.
Do not skip this. Every developer who skips local testing finds bugs on their live server. You will be more careful than that.
Step 1: Push Your Code to GitHub
GitHub is the bridge between Replit and your VPS. Your server will pull code from GitHub, not from Replit. If you have not already pushed your code, do it now.
Initialize a git repository if you do not have one: git init. Stage all files: git add.. Commit: git commit -m "Initial commit". Create a repository on GitHub. Add the remote: git remote add origin https://github.com/<your-username>/<your-repo>.git. Push: git push -u origin main.
Make sure you have a .gitignore file that excludes .env and node_modules (or venv, __pycache__, etc.). You do not want secrets in your repository, and you do not want to commit dependencies. GitHub should see only your source code.
Once pushed, your GitHub repository becomes the source of truth. When you update code locally, commit and push. When you are ready to deploy a change, you will pull from GitHub on your server.
Step 2: Choose Your VPS & Create the Server
You need a Linux VPS. DigitalOcean Droplets start at $5 per month ($0.0074 per hour). Hetzner Cloud starts at EUR 2.99 per month (roughly $3.30 USD). AWS EC2 has a free tier for the first year, then varies by instance size and region. Linode, Vultr, and Scaleway are also solid options.
For your first production app, pick the cheapest tier that covers your expected traffic. A 1GB RAM / 1 vCPU Droplet handles 10-50 concurrent users easily. Do not over-provision.
Choose a Linux distribution: Ubuntu 22.04 LTS is the safest choice. It has the largest community, the most tutorials, and long-term support. Get root SSH access to your server (most providers give you this automatically). Open a terminal on your laptop and verify you can connect: ssh root@your-server-ip. You should be inside the server's terminal within seconds.
Once inside, update the system: apt update && apt upgrade -y. This ensures you have the latest security patches. You are not production-ready until this is done.
Step 3: Clone Your Repo & Install Dependencies
On your VPS, create a directory for your app: mkdir -p /var/www/my-app. Navigate into it: cd /var/www/my-app. Clone your GitHub repository: git clone https://github.com/<your-username>/<your-repo>.git. (note the dot--it clones into the current directory).
Now install the language runtime and dependencies. For Node.js: install Node using NodeSource or Nodesource. Run apt install nodejs npm. Verify: node --version and npm --version. Then install your app's dependencies: npm install.
For Python: install Python, pip, and venv. Run apt install python3 python3-pip python3-venv. Create a virtual environment: python3 -m venv venv. Activate it: source venv/bin/activate. Install dependencies: pip install -r requirements.txt.
For other languages, follow the same pattern: install the runtime, install dependencies, verify nothing is broken.
Test everything: npm start or python app.py. Your app should start without errors. The app is still listening only on localhost--you cannot access it from your laptop yet. But if it starts without crashing, you have done this step correctly.
Step 4: Set Environment Variables & Migrate Your Database
This is where most deployments break. Replit stored your secrets inside the Replit UI. Your VPS does not have those secrets. You must add them manually.
On your VPS, create a .env file in your app directory: nano /var/www/my-app/.env. Copy every secret from your local .env file (the one you tested with locally). Paste them into the VPS .env. Save and exit. Now your app can read these secrets.
Be paranoid about security here. Never commit .env to git. Never log .env values. Never email .env to yourself. The only copy should be on your VPS, protected by file permissions: chmod 600 /var/www/my-app/.env. Only the app process can read it.
Next, migrate your database. If you used Replit App Storage, export it now. Log into Replit, go to your project settings, find the database section, and export as JSON or SQL. Download the export file. Upload it to your VPS: scp export.json your-user@your-server-ip:/var/www/my-app/.
If you want a fresh database hosted separately, consider Supabase (free PostgreSQL tier) or Neon (also free Postgres). Sign up, create a database, and get a connection string. Paste the connection string into your .env file. Test it: connect to the database from your VPS and verify you can query it.
Migrate your Replit data into the new database using your app's migration tools or a SQL dump. This is painful the first time. It gets easier.
Step 5: Start Your App & Keep It Running
Here is the trap: if you run npm start or python app.py directly on the VPS, your app will stop the moment you close your SSH connection. You need a process manager to run your app in the background, restart it if it crashes, and keep it running across server reboots.
For Node.js, use PM2. Install it globally: npm install -g pm2. Start your app: pm2 start app.js --name my-app. Verify it is running: pm2 list. Set it to start on reboot: pm2 startup and pm2 save. Your app will now restart automatically if it crashes or if the server reboots.
For Python, use Systemd (the init system built into Linux). Create a service file: sudo nano /etc/systemd/system/my-app.service. Paste this template:
[Unit]
Description=My Replit App
After=network.target
[Service]
Type=simple
User=root
WorkingDirectory=/var/www/my-app
Environment="PATH=/var/www/my-app/venv/bin"
ExecStart=/var/www/my-app/venv/bin/python app.py
Restart=always
RestartSec=10
[Install]
WantedBy=multi-user.target
Save and exit. Enable and start the service: sudo systemctl enable my-app and sudo systemctl start my-app. Verify it is running: sudo systemctl status my-app. If it crashes, Systemd will restart it automatically.
Your app is now running in the background on your VPS. It is listening on a local port (probably 3000, 5000, or 8000). You still cannot access it from the internet. That comes next.
Step 6: Set Up a Reverse Proxy & Point Your Domain
Your app is running on a local port (probably 3000). The internet uses ports 80 (HTTP) and 443 (HTTPS). You need a reverse proxy to listen on 80/443 and forward traffic to your app's internal port.
Nginx is the industry standard. Install it: apt install nginx. Create a configuration file: sudo nano /etc/nginx/sites-available/my-app. In the configuration, set the server_name directive to your domain, then use a proxy_pass directive to forward traffic to your app's local address and port. For example, if your app runs on port 3000, you would point proxy_pass to the loopback address on that port. Here is the basic structure:
server {
listen 80;
server_name your-domain.com www.your-domain.com;
location / {
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection 'upgrade';
proxy_set_header Host $host;
proxy_cache_bypass $http_upgrade;
}
}
Add a proxy_pass line inside the location block pointing to where your app listens (for example, the loopback interface and port 3000 if that is where your app runs). Save and exit.
Enable this configuration: sudo ln -s /etc/nginx/sites-available/my-app /etc/nginx/sites-enabled/. Test the syntax: sudo nginx -t. Reload Nginx: sudo systemctl reload nginx.
Now point your domain to your server. Log into your domain registrar (GoDaddy, Namecheap, Route53). Create or update an A record pointing to your server's IP address. Wait for DNS to propagate (usually a few minutes, sometimes up to 24 hours).
Test it: open a browser and navigate to your domain. Your app should load. Traffic flows like this: your browser -> Nginx on port 80 -> your app on its internal port.
Finally, add HTTPS. Use Certbot to get a free SSL certificate from Let's Encrypt: apt install certbot python3-certbot-nginx. Run: sudo certbot --nginx -d your-domain.com -d www.your-domain.com. Certbot will ask a few questions, then automatically configure Nginx for HTTPS. Your site is now secure, and Certbot will auto-renew your certificate every 90 days.
When to Stop DIY & Use Ship Instead
You have a working deployment. Your app is live. Congratulations. Now the question is: was it worth your time?
DIY wins on cost. A Hetzner Droplet costs EUR 2.99 per month plus your labor. A DigitalOcean Droplet is $5 per month plus your labor. If you value your time at $0 per hour, DIY is cheaper.
Ship (Opsily's managed hosting) charges a flat monthly fee. You do not provision servers, manage Nginx, debug PM2, or renew certificates. Ship handles all of that. You push code to GitHub, it deploys automatically. It scales if traffic spikes. It backs up your database. It sends alerts if something breaks. That flat price buys you peace of mind and your time back.
Northflank (the incumbent in this space) offers enterprise features: advanced scaling rules, multi-region deployments, fine-grained access controls. Ship offers simplicity: deploy once, know your cost, never wake up at 3 a.m. because Nginx crashed.
Choose Ship if: you have 10+ users and cannot afford downtime. You trust a managed provider with your data. You value predictable costs over rock-bottom pricing. You want GDPR-compliant hosting in the EU.
Choose DIY if: you have <10 users and can tolerate occasional downtime. You enjoy tinkering with servers. You need absolute cost minimization. You need custom infrastructure (multi-database, special networking, specific hardware).
Choose Northflank or Railway if: you need enterprise scaling and advanced features without managing servers yourself. You are willing to pay more for convenience than Ship charges.
There is no wrong answer. But be honest: if you are reading a deployment tutorial instead of shipping features, DIY probably costs you more than you think.
Frequently Asked Questions
How do I deploy my Replit app?
Export your code from Replit to GitHub. Clone it on a Linux VPS. Install dependencies. Set environment variables. Use PM2 or Systemd to keep it running. Point a reverse proxy (Nginx) at your app. Point your domain to the server. Test thoroughly before going live.
How much does Replit charge to host an app?
Replit's free tier hosts apps for 24 hours. After that, your app goes to sleep. Replit's paid tier (Replit Core) is $7 per month and keeps apps always-on. Ship's managed hosting starts lower but varies by resource needs. For comparison, DigitalOcean Droplets start at $5/month and Hetzner at EUR 2.99/month.
Can I deploy a Replit app for free?
Yes. The free tier of most VPS providers (AWS EC2 with free tier, Render's free tier for Node apps) will host a small Replit app. But free tiers come with limits: limited CPU, limited bandwidth, instance shutdown after a certain time on Render. For production apps, expect to pay $3-$20 per month depending on traffic and resource needs.
How to run a Replit app locally?
Clone your Replit repository to your laptop. Install your language runtime (Node, Python, Ruby, etc.). Install dependencies (npm install, pip install -r requirements.txt, etc.). Create a.env file with your secrets. Run your app (npm start, python app.py, etc.). Test it on port 3000 before deploying anywhere.
Can I publish a Replit app to the App Store?
Not directly. App Stores (Apple App Store, Google Play) distribute mobile or native apps, not web apps. If your Replit app is a web app, publish it as a web service (via a domain name). If it is a Node app or Python package, you can publish to npm or PyPI. If you want it on App Stores, you will need to wrap it as a native app using frameworks like React Native or Flutter.
Can you export code from Replit?
Yes. In Replit, click the three-dot menu and select "Export as zip" or "Connect to GitHub" to push your code to a GitHub repository. We have a detailed guide on how to export your app from Replit that covers both methods.
The Bottom Line
Deploying a Replit app to your own server takes two to four hours if you are following a tutorial. You gain control, reduce vendor lock-in, and own your infrastructure. The tradeoff: you are now responsible for uptime, security updates, and scaling.
If you want the control without the operational burden, explore Ship hosting, which automates the entire process and includes EU data residency options for GDPR compliance.