Deploy Coder — Self-Hosted Dev Environments Control Plane
Open-source Codespaces alternative — control plane + Postgres
Just deployed
/var/lib/postgresql/data
Coder
Just deployed
Deploy and Host Coder on Railway
Coder is the leading open-source platform for self-hosted cloud development environments — an alternative to GitHub Codespaces and Gitpod that keeps your source code and compute on infrastructure you control. Define workspaces in Terraform, onboard developers in minutes, and run AI coding agents inside governed environments. This template deploys the Coder control plane with a managed PostgreSQL database, ready to orchestrate workspaces on your own compute.
What This Template Deploys
| Service | Purpose |
|---|---|
| Coder Server | The control plane — web dashboard, API, user management, and template engine on port 3000 |
| PostgreSQL | Users, workspace metadata, template definitions, audit logs, and session state |
Both services run on Railway's private network with the database connection injected automatically. Coder requires PostgreSQL 13+ and cannot persist any state without it.
About Hosting Coder
There is one thing to understand before deploying, and it shapes everything: Railway runs the Coder control plane, not the workspaces themselves.
Coder provisions development environments using Terraform, targeting Docker, Kubernetes, or cloud VMs. Railway provides none of those as a workspace host — no Docker-in-Docker, no Kubernetes. So on Railway, Coder runs as a control plane only: the dashboard, API, user management, templates, and audit logs all work fully, but the actual workspace compute runs elsewhere, connected through an external provisioner.
This is the correct and supported architecture, not a limitation to work around — Coder is designed to separate the control plane from workspace compute. In practice: deploy this template for a working Coder server, install the Coder CLI on a machine with Docker or Kubernetes access, set CODER_PROVISIONER_DAEMON_PSK as a shared secret on both sides, run coder provisioner start --psk --url https://your-coder-url, and workspaces then provision on that connected infrastructure rather than on Railway.
If you deploy expecting workspaces to run on Railway itself, you'll reach the dashboard and be unable to create a workspace. That's expected: the compute is meant to live on your own hosts.
Typical cost: ~$5–10/month on Railway for the control plane and Postgres, plus whatever your workspace compute costs on its own host. Codespaces and Gitpod bill per hour of active workspace usage; Coder lets you run that compute on your cheapest available infrastructure — or shut it down entirely when idle.
How It Compares
| Coder (self-hosted) | GitHub Codespaces | Gitpod Cloud | Coder Cloud | |
|---|---|---|---|---|
| Cost model | Your infra + ~$5/mo control plane | Per compute hour | Per compute hour | Per user/month |
| Compute location | Your own hosts/cloud | GitHub cloud | Gitpod cloud | Coder-managed |
| Source code location | Your infrastructure | GitHub cloud | Gitpod cloud | Your infra |
| Workspace definition | Terraform (any resource) | devcontainer.json | Gitpod YAML | Terraform |
| GPU workspaces | Yes, on your compute | Limited | Limited | Yes |
| Self-hostable | Yes | No | No | No |
Codespaces and Gitpod are zero-setup but run your code on their cloud and bill per hour. Coder wins when you need source code and compute on your own infrastructure — for security, cost control, GPU access, or governing AI coding agents — at the cost of connecting your own workspace hosts.
Deploy in Under 5 Minutes
- Click Deploy on Railway — Coder and PostgreSQL build automatically (~3 minutes)
- Add a custom domain in Railway (required if you want web port-forwarding — see below)
- Set
CODER_ACCESS_URLto your Coder URL - Open the URL and complete the first-time setup wizard to create your admin account
- Connect an external provisioner to start creating workspaces on your own compute
The dashboard, templates, and user management work immediately; workspace provisioning needs the provisioner step.
Common Use Cases
- Open-source Codespaces alternative — cloud dev environments where source code stays on your own infrastructure
- Fast developer onboarding — Terraform-defined, repeatable environments spin up in minutes instead of days of local setup
- Governed AI coding agents — run coding agents inside controlled cloud environments with full control over compute, access, and context
- Security-hardened teams — keep code off local laptops entirely, on managed infrastructure you audit
Configuration
| Variable | Required | Description |
|---|---|---|
CODER_PG_CONNECTION_URL | Auto-injected | PostgreSQL connection via Railway reference variable |
CODER_ACCESS_URL | Required | The URL where Coder is reachable — your Railway domain or custom domain |
CODER_HTTP_ADDRESS | Pre-set | 0.0.0.0:3000 so Railway can route to the service |
CODER_WILDCARD_ACCESS_URL | Optional | Wildcard subdomain (e.g. *.coder.example.com) for web port-forwarding — needs a custom domain |
CODER_PROVISIONER_DAEMON_PSK | Recommended | Shared secret for connecting external provisioners that run your workspaces |
CODER_OAUTH2_GITHUB_* | Optional | GitHub OAuth for developer sign-in |
> CODER_WILDCARD_ACCESS_URL needs a custom domain. Railway's built-in .up.railway.app domain doesn't support the wildcard subdomains required for web port forwarding. Add a custom domain and point a wildcard at it if you need that feature — Coder works without it, you just lose dashboard port-forwarding.
> Workspaces run on external compute, not Railway. Set CODER_PROVISIONER_DAEMON_PSK and connect a Docker or Kubernetes host with coder provisioner start. Without a provisioner, the dashboard works but no workspaces can be created.
Dependencies for Coder Hosting
- Railway account — Hobby plan (~$5–10/month) covers the control plane and Postgres
- A separate machine with Docker or Kubernetes access to run workspaces (your VPS, cloud VM, or K8s cluster)
- A custom domain if you want web-based port forwarding
- Optional: cloud provider credentials for cloud-VM workspace templates (AWS, GCP, Azure)
Deployment Dependencies
Implementation Details
The template runs the official Coder server image on port 3000 against a managed Railway PostgreSQL service, connected through CODER_PG_CONNECTION_URL. Coder requires PostgreSQL 13 or later and stores all persistent state — users, workspace metadata, template definitions, audit logs, and sessions — there; without it, nothing survives a restart.
Because Railway does not offer Docker-in-Docker or Kubernetes, this deployment is the control plane only. Workspace compute is provided by external provisioners: the Coder CLI running on a machine with Docker or Kubernetes access, authenticated to this server with a shared PSK (CODER_PROVISIONER_DAEMON_PSK). This is Coder's intended separation of orchestration from compute, and it lets the control plane sit cheaply on Railway while workspaces run wherever compute is cheapest.
CODER_ACCESS_URL must match how Coder is reached. The optional CODER_WILDCARD_ACCESS_URL enables dashboard port-forwarding but requires a custom domain, since Railway's default domain doesn't support the wildcard subdomains it needs.
Frequently Asked Questions
Can I run developer workspaces on Railway itself? No. Coder provisions workspaces onto Docker, Kubernetes, or cloud VMs, and Railway provides none of those as a workspace host. This deployment is the control plane; connect an external provisioner running on your own Docker or K8s host to create workspaces.
How do I connect external compute? Install the Coder CLI on a machine with Docker or Kubernetes access, set CODER_PROVISIONER_DAEMON_PSK as a shared secret on both sides, and run coder provisioner start --psk --url https://your-coder-url. Workspaces then provision on that machine.
Why does it need PostgreSQL? Coder stores users, workspace metadata, templates, audit logs, and session state in PostgreSQL 13+. Without it, no configuration persists between restarts. The template provisions and connects it for you.
Why doesn't port forwarding work? Web-based port forwarding needs CODER_WILDCARD_ACCESS_URL, which requires wildcard subdomains. Railway's default .up.railway.app domain doesn't support those — add a custom domain to enable it.
Is this really cheaper than Codespaces? The control plane is a flat ~$5–10/month; your workspace compute costs whatever its host costs and can be shut down when idle. Codespaces and Gitpod bill per active hour, so for steady use Coder on your own compute is typically cheaper.
Can I run AI coding agents on it? Yes. Coder is increasingly used to run AI coding agents inside governed cloud environments, giving control over their compute, access, and context without exposing sensitive systems.
Why Deploy Coder 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 Coder's control plane on Railway you get a cloud development platform's orchestration layer running in minutes — dashboard, API, templates, and user management with a managed PostgreSQL backend and automatic HTTPS — while your workspace compute runs on your own infrastructure. Own your dev environments, keep source code off local machines, and control exactly where your compute lives.
Template Content
