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
Configure replit.nix with multiple runtimes
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.
1# replit.nix — Python + Node.js + Go2{ pkgs }: {3 deps = [4 pkgs.python3105 pkgs.python310Packages.pip6 pkgs.nodejs-20_x7 pkgs.go_1_218 pkgs.pkg-config9 ];10}Expected result: Running 'python --version', 'node --version', and 'go version' in Shell confirms all three runtimes are installed and accessible.
Set up the project directory structure
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.
1# Recommended directory structure:2# project-root/3# ├── .replit4# ├── replit.nix5# ├── backend/6# │ ├── main.py7# │ ├── requirements.txt8# │ └── ...9# ├── frontend/10# │ ├── package.json11# │ ├── src/12# │ └── ...13# └── shared/14# └── config.jsonExpected result: Your project has a clean directory structure with separate folders for each language runtime.
Install dependencies for each runtime
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.
1# Install Python dependencies:2cd backend && pip install -r requirements.txt && cd ..34# Install Node.js dependencies:5cd frontend && npm install && cd ..67# 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.
Write a multi-process run command in .replit
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.
1# .replit — multi-process run command2entrypoint = "backend/main.py"34run = "cd backend && python main.py & cd frontend && npm run dev & wait"56onBoot = "cd backend && pip install -r requirements.txt && cd ../frontend && npm install"78[nix]9channel = "stable-24_05"1011[[ports]]12localPort = 500013externalPort = 801415[[ports]]16localPort = 300017externalPort = 30001819[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.
Configure port mapping for multi-service apps
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.
1# .replit — port mapping for Python backend (5000) and React frontend (3000)2[[ports]]3localPort = 50004externalPort = 8056[[ports]]7localPort = 30008externalPort = 3000910# backend/main.py — Flask on port 5000:11from flask import Flask12app = Flask(__name__)1314@app.route('/api/hello')15def hello():16 return {'message': 'Hello from Python!'}1718if __name__ == '__main__':19 app.run(host='0.0.0.0', port=5000)2021# 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.
Configure deployment for multi-runtime projects
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.
1# .replit — deployment configuration for multi-runtime2[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"67# In this setup, the Python backend serves the built frontend:8# backend/main.py addition:9import os10from flask import Flask, send_from_directory1112app = Flask(__name__, static_folder='../frontend/dist')1314@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
1# .replit — Multi-runtime configuration (Python + Node.js)2# This file runs a Python Flask backend and a React frontend simultaneously34entrypoint = "backend/main.py"56# Development: run both servers in parallel7run = "cd backend && python main.py & cd frontend && npm run dev & wait"89# Auto-install dependencies on workspace start10onBoot = "cd backend && pip install -r requirements.txt && cd ../frontend && npm install"1112[nix]13channel = "stable-24_05"14packages = ["python310", "nodejs-20_x"]1516# Port mapping17[[ports]]18localPort = 500019externalPort = 802021[[ports]]22localPort = 300023externalPort = 30002425# Environment variables for development26[run.env]27FLASK_ENV = "development"28NODE_ENV = "development"29PYTHONUNBUFFERED = "1"3031# Deployment: build frontend, serve from backend32[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"3637# Hide non-essential files38hidden = [".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.
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?
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.
Talk to an Expert
Our team has built 600+ apps. Get personalized help with your project.
Book a free consultation