---
title: "Deploy Self-Host Plandex — AI Coding Agent for Large Codebases on Railway"
description: "Self-host Plandex: 2M token context, plan version control, BYO API keys."
category: "AI/ML"
url: https://railway.com/deploy/plandex-ai-coding-server
---

# Deploy Self-Host Plandex — AI Coding Agent for Large Codebases on Railway

Self-host Plandex: 2M token context, plan version control, BYO API keys.

**[Deploy Self-Host Plandex — AI Coding Agent for Large Codebases on Railway on Railway](https://railway.com/template/plandex-ai-coding-server)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/plandex-ai-coding-server/manifest.json

- **Creator:** SilverBanana
- **Category:** AI/ML
- **Total deploys:** 2

## Template content

### Postgres https://devicons.railway.app/i/postgresql.svg

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:18

### plandexai/plandex-server:latest

- **Image:** plandexai/plandex-server:latest
- **Public domain:** Yes

## Documentation

# Deploy and Host Plandex on Railway

Plandex is an open-source terminal AI coding agent with **10k+ GitHub stars** built for
what other AI coding tools can't handle — large, multi-file, real-world development tasks.
**2M token context window**, tree-sitter project maps for 30+ languages, a cumulative diff
review sandbox, full plan version control with branching and rollback, and a BYO API key
model that routes through 11+ providers from a single self-hosted server.

With Plandex Cloud winding down, self-hosting on Railway is now the primary path forward —
your team's shared AI coding server, your API keys, your code, fully under your control.

---

## What This Template Deploys

| Service | Purpose |
|---|---|
| **Plandex Server** | Go-based API server with embedded LiteLLM proxy — manages plans, context, conversation history, and multi-provider LLM routing on port `8099` |
| **PostgreSQL 18** | Persistent database for plan metadata, user accounts, and migrations |
| **Plan Storage Volume (`/plandex-server`)** | Persistent volume for plan file state — plan history and diffs survive every redeploy |

The Plandex CLI runs on developer machines and connects to this Railway server. LLM API keys
stay on developer machines — never stored server-side.

---

## About Hosting Plandex

Plandex is a client-server architecture: the CLI runs locally and the server handles plan
orchestration, multi-file context management, version control, and model routing. Running
the server in production requires PostgreSQL for metadata, a persistent volume for plan
storage, and a public HTTPS endpoint for CLI connections. Without a managed host, you're
configuring Docker Compose, PostgreSQL, SSL, and volume mounts manually.

Railway provisions all of it. This template deploys the Plandex server pre-connected to a
Railway PostgreSQL instance with a persistent plan storage volume — your team connects
immediately after deploy by pointing the CLI at your Railway domain.

Typical cost: **~$5–10/month** on Railway's Hobby plan for the full stack. GitHub Copilot
costs $10–19/user/month. Cursor costs $20/user/month. Plandex self-hosted on Railway gives
your entire team a shared AI coding server at flat compute cost — you pay only your LLM API
usage, not a per-seat subscription.

---

## Deploy in Under 5 Minutes

1. Click **Deploy on Railway** — Plandex server and PostgreSQL provision automatically
2. Open your Railway-assigned URL — the server is live on port `8099`
3. Install the Plandex CLI on your local machine:
   ```
   curl -sL https://plandex.ai/install.sh | bash
   ```
4. Point the CLI at your Railway server:
   ```
   export PLANDEX_API_URL=https://your-railway-domain.up.railway.app
   plandex sign-in
   ```
5. `cd` into your project, run `plandex new`, and start building with AI

No server management. No Docker configuration. No SSL certificates to manage.

---

## Common Use Cases

- **Self-hosted Plandex Cloud replacement** — Plandex Cloud is winding down; deploy on
  Railway to keep all your AI coding workflows running on infrastructure you control with
  no feature loss and no migration overhead
- **Self-hosted alternative to Cursor** — replace $20/user/month per-seat billing with a
  shared team server at flat compute cost; BYO API keys mean you control your LLM spend
- **Large codebase refactoring and feature development** — plan and execute changes across
  50+ files with a 2M token context window and tree-sitter maps; where GitHub Copilot
  suggests snippets, Plandex executes multi-step implementations
- **Team AI coding server with shared plan history** — multiple developers connect to the
  same Railway-hosted Plandex server; share plans, review AI changes, and collaborate on
  AI-assisted development without per-seat licensing
- **Autonomous debugging and command execution** — Plandex runs terminal commands, detects
  errors, and iterates automatically in full-auto mode — or waits for your review at each
  step in controlled mode
- **Multi-model AI coding workflows** — mix Anthropic Claude, OpenAI, Google Gemini,
  DeepSeek, and Ollama in a single plan using model packs; optimise for speed, cost, or
  quality per task

---

## Configuration

| Variable | Required | Description |
|---|---|---|
| `DATABASE_URL` | ✅ Auto-injected | PostgreSQL connection string — injected from the Railway PostgreSQL service |
| `GOENV` | Pre-set | `development` — skips email verification. Set to `production` for SMTP-verified signups |
| `LOCAL_MODE` | Pre-set | `1` — disables email verification in development mode |
| `PLANDEX_BASE_DIR` | Pre-set | `/plandex-server` — plan file storage directory, matches the persistent volume mount |
| `PORT` | Pre-set | `8099` — Plandex server port, auto-configured |
| `API_HOST` | Required in production | Your Railway public URL — required when `GOENV=production` |
| `SMTP_HOST` | Optional | SMTP server for email verification in production mode |
| `SMTP_PORT` | Optional | SMTP port — typically `587` |
| `SMTP_USER` | Optional | SMTP username |
| `SMTP_PASSWORD` | Optional | SMTP password |

> For team deployments, set `GOENV=production` and configure SMTP variables to enable
> email-verified account creation. In `development` mode with `LOCAL_MODE=1`, any email
> address signs in immediately without verification.

---

## Plandex vs. AI Coding Alternatives

| | Plandex (self-hosted) | GitHub Copilot | Cursor | Claude Code |
|---|---|---|---|---|
| **Cost** | ~$5–10/mo flat | $10–19/user/mo | $20/user/mo | BYO API only |
| **Per-seat billing** | ✅ None | ❌ Yes | ❌ Yes | ✅ None |
| **Context window** | ✅ 2M tokens direct | ⚠️ Limited | ⚠️ Limited | ✅ Large |
| **Multi-file execution** | ✅ 50+ files | ⚠️ Inline only | ⚠️ Composer | ✅ Yes |
| **Plan version control** | ✅ Branch + rollback | ❌ No | ❌ No | ❌ No |
| **Diff review sandbox** | ✅ Yes | ❌ No | ⚠️ Limited | ❌ No |
| **Self-hostable** | ✅ Yes | ❌ No | ❌ No | ❌ No |
| **BYO API keys** | ✅ Yes | ❌ No | ⚠️ Partial | ✅ Yes |
| **Multi-model support** | ✅ 11+ providers | ❌ GitHub only | ✅ Yes | ❌ Anthropic only |
| **Team shared server** | ✅ Yes | ❌ Per-seat | ❌ Per-seat | ❌ Local only |

---

## Dependencies for Plandex Hosting

- Railway account — Hobby plan (~$5–10/month) covers the full stack
- LLM API key per developer — Anthropic, OpenAI, Google, DeepSeek, or OpenRouter

### Deployment Dependencies

- [Plandex GitHub Repository](https://github.com/plandex-ai/plandex) — source and releases
- [Plandex Documentation](https://docs.plandex.ai) — CLI setup and server configuration
- [Plandex Docker Hub](https://hub.docker.com/r/plandexai/plandex-server) — server image
- [Railway Volumes Documentation](https://docs.railway.com/volumes) — plan storage setup

### Implementation Details

This template deploys `plandexai/plandex-server:latest` alongside Railway-managed PostgreSQL
over private networking. The Go server embeds a Python LiteLLM proxy subprocess routing
API calls to Anthropic, OpenAI, Google, xAI, OpenRouter, Ollama, and DeepSeek. LLM keys
are passed via CLI per session and never stored server-side. Plan files and version history
persist on the `/plandex-server` volume; user accounts and metadata persist in PostgreSQL.
Both survive redeploys and version updates independently.

---

## Frequently Asked Questions

**Plandex Cloud is winding down — how do I migrate to self-hosting?**
Deploy this Railway template, set `PLANDEX_API_URL` to your Railway domain, and create a
new account. Existing Plandex Cloud plan history is not automatically migrated, but all new
plans run on your instance with identical functionality and full data ownership.

**How much does Plandex self-hosted cost vs Cursor or GitHub Copilot?**
The Railway server runs at ~$5–10/month flat for the full stack. GitHub Copilot costs
$10–19/user/month per seat. Cursor costs $20/user/month. For a 5-person team, that's
$50–100/month in seat licensing versus ~$5–10/month flat on Railway plus your actual LLM
API usage.

**How is Plandex different from GitHub Copilot or Cursor?**
Copilot and Cursor are inline autocomplete tools — they suggest code as you type. Plandex
plans and executes multi-step implementations across 50+ files with a 2M token context
window, built-in plan version control, branching, rollback, and a diff review sandbox.
It's designed for tasks where autocomplete falls short: large refactors, full feature builds,
and complex debugging across a real codebase.

**Do my API keys get stored on the Railway server?**
No. LLM API keys stay on developer machines and are passed through the CLI per session.
The Plandex server never stores API credentials. Your code context is processed through
the server for plan orchestration but is not retained beyond the active plan session.

**Can multiple developers share the same Railway-hosted server?**
Yes. The Plandex server is designed for team use. Each developer installs the CLI, points
it at the same Railway URL, creates their own account, and works on independent plans.
Plan history is per-user by default with optional sharing.

**How do I update Plandex to a newer version?**
Update the image tag in your Railway service settings to the latest release (e.g.
`plandexai/plandex-server:2.1.0`) and redeploy. PostgreSQL data and plan storage volume
are unaffected. Update the CLI on developer machines separately via the install script.

---

## Why Deploy and Host Plandex on Railway?

Railway is a singular platform to deploy your infrastructure stack. Railway will host your
infrastructure so you don't have to deal with configuration, while allowing you to vertically
and horizontally scale it.

By deploying Plandex on Railway, you get a production-ready shared AI coding server for your
team — 2M token context, plan version control, multi-model routing, diff review sandbox, and
full data ownership — at ~$5–10/month flat with no per-seat fees.

## Similar templates

- [Chat Chat](https://railway.com/deploy/-WWW5r) — Chat Chat, your own unified chat and search to AI platform.
- [stella](https://railway.com/deploy/stella) — Self-host stella with web, API, Postgres, Redis, and object storage.
- [Hermes Agent | OpenClaw Alternative with Dashboard](https://railway.com/deploy/hermes-agent-or-openclaw-alternative-wit) — Self-Hosted Hermes AI Agent for Telegram, Discord & Slack

Open this page in a browser: https://railway.com/deploy/plandex-ai-coding-server
