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

How to use multiple runtimes in Replit

Replit supports multiple runtime environments in a single project through Nix and the .replit configuration file. You can run Python and Node.js side by side by adding both runtimes to replit.nix and using a multi-process run command in .replit. The key is the run command syntax — use '&' to launch processes in parallel and 'wait' to keep them alive. This works for any combination of languages Nix supports.

What you'll learn

  • Configure replit.nix to install multiple language runtimes
  • Write a multi-process run command in .replit using & and wait
  • Manage separate entry points and environments for each runtime
  • Handle port configuration for multi-service applications
Book a free consultation
4.9Clutch rating
600+Happy partners
17+Countries served
190+Team members
Beginner9 min read10-15 minutesAll Replit plans (Starter, Core, Pro). Works with any combination of Nix-supported runtimes (Python, Node.js, Go, Ruby, Rust, etc.).March 2026RapidDev Engineering Team
TL;DR

Replit supports multiple runtime environments in a single project through Nix and the .replit configuration file. You can run Python and Node.js side by side by adding both runtimes to replit.nix and using a multi-process run command in .replit. The key is the run command syntax — use '&' to launch processes in parallel and 'wait' to keep them alive. This works for any combination of languages Nix supports.

Run Python, Node.js, and Other Runtimes Together in One Replit Project

This tutorial shows you how to configure a Replit project that uses multiple programming languages simultaneously. Common use cases include a Python backend with a React frontend, a Node.js API alongside a Python data processing script, or a Go microservice with a Python ML model. You will configure the Nix environment to install multiple runtimes, set up a multi-process run command, and manage per-process environment variables.

Prerequisites

  • A Replit account (free Starter plan works)
  • Basic familiarity with the Replit workspace (Shell, file tree, .replit file)
  • Understanding of what .replit and replit.nix files control
  • A project idea that requires two or more languages

Step-by-step guide

1

Configure replit.nix with multiple runtimes

Open the replit.nix file in your project root (enable Show hidden files if you do not see it). Add the package declarations for each language runtime you need. Nix uses a declarative syntax where you list packages in the deps array. After editing, type 'exit' in the Shell to restart the Nix environment and make the new runtimes available. You can search for available packages at search.nixos.org/packages.

typescript
1# replit.nix Python + Node.js + Go
2{ pkgs }: {
3 deps = [
4 pkgs.python310
5 pkgs.python310Packages.pip
6 pkgs.nodejs-20_x
7 pkgs.go_1_21
8 pkgs.pkg-config
9 ];
10}

Expected result: Running 'python --version', 'node --version', and 'go version' in Shell confirms all three runtimes are installed and accessible.

2

Set up the project directory structure

Organize your project so each language has its own directory. This keeps dependencies, configuration, and source files separate and prevents naming conflicts. A typical layout has a backend directory for the Python/Go server and a frontend directory for the Node.js/React app. Each directory has its own dependency files (requirements.txt, package.json, go.mod). The root .replit file orchestrates everything.

typescript
1# Recommended directory structure:
2# project-root/
3# .replit
4# replit.nix
5# backend/
6# main.py
7# requirements.txt
8# ...
9# frontend/
10# package.json
11# src/
12# ...
13# shared/
14# config.json

Expected result: Your project has a clean directory structure with separate folders for each language runtime.

3

Install dependencies for each runtime

Open the Shell tab and install dependencies for each language in its respective directory. Navigate to each directory and run the appropriate package manager. You can also use the onBoot command in .replit to automate dependency installation when the workspace starts.

typescript
1# Install Python dependencies:
2cd backend && pip install -r requirements.txt && cd ..
3
4# Install Node.js dependencies:
5cd frontend && npm install && cd ..
6
7# Or automate with onBoot in .replit:
8# onBoot = "cd backend && pip install -r requirements.txt && cd ../frontend && npm install"

Expected result: All dependencies are installed for each runtime. Importing packages in test scripts works without errors.

4

Write a multi-process run command in .replit

The key to running multiple runtimes is the run command in .replit. Use the & operator to launch multiple processes in parallel, and end with 'wait' to keep the Run button active until all processes exit. Each process runs independently with its own stdout/stderr visible in the Console. You can also set environment variables per process using inline export statements or the [run.env] section.

typescript
1# .replit multi-process run command
2entrypoint = "backend/main.py"
3
4run = "cd backend && python main.py & cd frontend && npm run dev & wait"
5
6onBoot = "cd backend && pip install -r requirements.txt && cd ../frontend && npm install"
7
8[nix]
9channel = "stable-24_05"
10
11[[ports]]
12localPort = 5000
13externalPort = 80
14
15[[ports]]
16localPort = 3000
17externalPort = 3000
18
19[run.env]
20FLASK_ENV = "development"
21NODE_ENV = "development"

Expected result: Pressing the Run button starts both the Python backend and Node.js frontend simultaneously. Both processes show output in the Console.

5

Configure port mapping for multi-service apps

When running multiple servers, each needs its own port. Configure the [[ports]] section in .replit to map each local port to an external port. The primary service (usually the API or the frontend proxy) should map to external port 80 since that is what Replit's Preview pane and deployment health check use. Other services can use different external ports. Make sure your servers bind to 0.0.0.0, not localhost.

typescript
1# .replit port mapping for Python backend (5000) and React frontend (3000)
2[[ports]]
3localPort = 5000
4externalPort = 80
5
6[[ports]]
7localPort = 3000
8externalPort = 3000
9
10# backend/main.py Flask on port 5000:
11from flask import Flask
12app = Flask(__name__)
13
14@app.route('/api/hello')
15def hello():
16 return {'message': 'Hello from Python!'}
17
18if __name__ == '__main__':
19 app.run(host='0.0.0.0', port=5000)
20
21# frontend/vite.config.js proxy API calls to Python backend:
22export default {
23 server: {
24 host: '0.0.0.0',
25 port: 3000,
26 proxy: {
27 '/api': 'http://localhost:5000'
28 }
29 }
30};

Expected result: Both servers start on their respective ports. The Preview pane shows the frontend, and API calls are proxied to the Python backend.

6

Configure deployment for multi-runtime projects

For production deployment, you need to decide how to serve both runtimes. The simplest approach is to build the frontend into static files and serve them from the backend. Alternatively, run both processes in the deployment using the same multi-process command. Update the deployment section in .replit with a build command that installs all dependencies and builds the frontend, and a run command that starts both services.

typescript
1# .replit deployment configuration for multi-runtime
2[deployment]
3build = ["sh", "-c", "cd backend && pip install -r requirements.txt && cd ../frontend && npm install && npm run build"]
4run = ["sh", "-c", "cd backend && python main.py"]
5deploymentTarget = "cloudrun"
6
7# In this setup, the Python backend serves the built frontend:
8# backend/main.py addition:
9import os
10from flask import Flask, send_from_directory
11
12app = Flask(__name__, static_folder='../frontend/dist')
13
14@app.route('/', defaults={'path': ''})
15@app.route('/<path:path>')
16def serve(path):
17 if path and os.path.exists(os.path.join(app.static_folder, path)):
18 return send_from_directory(app.static_folder, path)
19 return send_from_directory(app.static_folder, 'index.html')

Expected result: The deployed app serves the built frontend from the Python backend on a single port, with API routes handled server-side.

Complete working example

.replit
1# .replit Multi-runtime configuration (Python + Node.js)
2# This file runs a Python Flask backend and a React frontend simultaneously
3
4entrypoint = "backend/main.py"
5
6# Development: run both servers in parallel
7run = "cd backend && python main.py & cd frontend && npm run dev & wait"
8
9# Auto-install dependencies on workspace start
10onBoot = "cd backend && pip install -r requirements.txt && cd ../frontend && npm install"
11
12[nix]
13channel = "stable-24_05"
14packages = ["python310", "nodejs-20_x"]
15
16# Port mapping
17[[ports]]
18localPort = 5000
19externalPort = 80
20
21[[ports]]
22localPort = 3000
23externalPort = 3000
24
25# Environment variables for development
26[run.env]
27FLASK_ENV = "development"
28NODE_ENV = "development"
29PYTHONUNBUFFERED = "1"
30
31# Deployment: build frontend, serve from backend
32[deployment]
33build = ["sh", "-c", "cd backend && pip install -r requirements.txt && cd ../frontend && npm install && npm run build"]
34run = ["sh", "-c", "cd backend && python main.py"]
35deploymentTarget = "cloudrun"
36
37# Hide non-essential files
38hidden = [".config", "frontend/node_modules", "__pycache__"]

Common mistakes when using multiple runtimes in Replit

Why it's a problem: Forgetting the 'wait' command at the end of a multi-process run command

How to avoid: Without 'wait', the Run button stops immediately after launching background processes. Add '& wait' at the end: 'python app.py & npm run dev & wait'.

Why it's a problem: Not typing 'exit' in Shell after modifying replit.nix, so new packages are not loaded

How to avoid: After any change to replit.nix, type 'exit' in the Shell tab and wait for the environment to reload. Only then are new packages available.

Why it's a problem: Both servers trying to use the same port, causing one to fail with 'address already in use'

How to avoid: Assign different ports to each server (e.g., Python on 5000, Node.js on 3000) and map them separately in the [[ports]] section.

Why it's a problem: Running separate processes in deployment instead of building frontend to static files

How to avoid: For production, build the frontend with npm run build and serve the dist directory from your backend. This is simpler, cheaper, and avoids multi-process management in production.

Best practices

  • Keep each language in its own directory with separate dependency files (requirements.txt, package.json)
  • Always end multi-process run commands with 'wait' to keep the Run button active
  • Bind all servers to 0.0.0.0 so they are accessible from the Replit Preview pane
  • Use the frontend dev server's proxy feature to route API calls to the backend and avoid CORS issues
  • Set PYTHONUNBUFFERED=1 in [run.env] so Python output appears immediately in the Console
  • Use onBoot to auto-install dependencies so collaborators get a working environment automatically
  • For deployment, build the frontend into static files and serve them from the backend on a single port
  • Type 'exit' in Shell after modifying replit.nix to reload the Nix environment

Still stuck?

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

ChatGPT Prompt

I want to run a Python Flask API and a React frontend in the same Replit project. How do I configure replit.nix for both runtimes, set up a multi-process run command in .replit, and handle port mapping so both servers work in the Preview pane?

Replit Prompt

Configure this project for both Python and Node.js. Set up replit.nix with python310 and nodejs-20_x, create a backend directory with a Flask API on port 5000, create a frontend directory with a Vite React app on port 3000 that proxies /api to the backend, and update .replit to run both simultaneously.

Frequently asked questions

Yes. Add both runtimes to replit.nix (pkgs.python310 and pkgs.nodejs-20_x), then use a multi-process run command in .replit: 'python backend/main.py & npm --prefix frontend run dev & wait'.

replit.nix is a configuration file that tells Replit which system-level packages to install using the Nix package manager. It creates a reproducible environment with the exact runtimes and tools your project needs. Without it, only the default language for your Repl type is available.

There is no hard limit on the number of runtimes, but each one consumes RAM and CPU. On the free Starter plan (2 GiB RAM), two lightweight runtimes work fine. Three or more may cause out-of-memory errors. Core (8 GiB) and Pro (8+ GiB) plans support more concurrent processes.

Yes. Type 'exit' in the Shell tab after modifying replit.nix. This reloads the Nix environment and makes newly added packages available. Without this step, the new packages will not be found.

Use the frontend dev server's proxy feature instead of configuring CORS headers. In vite.config.js, add proxy: { '/api': 'http://localhost:5000' } to route API calls to the backend. This avoids CORS entirely during development.

Yes. Ask Agent: 'Create a project with a Python Flask API in a backend directory and a React frontend in a frontend directory. Configure replit.nix for both runtimes and set up a multi-process run command.' Agent v4 will scaffold the entire setup.

For projects with complex multi-service architectures, microservice communication patterns, or infrastructure requirements beyond what a single Repl supports, the RapidDev engineering team can help design a scalable architecture using proper service separation and orchestration.

Environment variables set in Tools → Secrets are available to all processes regardless of language. Access them with os.getenv('KEY') in Python and process.env.KEY in Node.js. Variables set in [run.env] in .replit are also available to all processes.

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.