---
title: "Deploy Background Agent"
description: "Deploy and host coding agents (opencode/claude code/codex) on Railway"
category: "AI/ML"
url: https://railway.com/deploy/background-agent
---

# Deploy Background Agent

Deploy and host coding agents (opencode/claude code/codex) on Railway

**[Deploy Background Agent on Railway](https://railway.com/template/background-agent)**

- **Creator:** My Projects
- **Category:** AI/ML
- **Total deploys:** 2

## Template content

### api

- **Source:** https://github.com/sidpalas/background-agent-railway
- **Public domain:** Yes

### web

- **Source:** https://github.com/sidpalas/background-agent-railway
- **Public domain:** Yes

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

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

## Documentation

# Deploy and Host Background Agent on Railway

Background Agent is a small full-stack demo that provisions per-session "sandbox" services on Railway and routes traffic to them through a proxy. 

It's inspired by Ramp's Background Agent architecture (https://builders.ramp.com/post/why-we-built-our-background-agent). You get an admin dashboard to create/retire ephemeral environments and a secure token-based link to open each sandbox in the browser.

## About Hosting Background Agent
Hosting Background Agent on Railway involves deploying:
- API service (Express + TypeScript)
- Web dashboard (React + Vite)
- Postgres database to track session state. 

When a user creates a session, the API uses the Railway GraphQL API to spin up a new Railway service from a sandbox container image. The API then reverse-proxies HTTP + WebSocket traffic to the correct sandbox over Railway's internal network, using a signed token to authorize access. 

You'll configure two public hostnames: one for the API/dashboard and one dedicated to proxying sandbox traffic.

## Common Use Cases
- Ephemeral dev/test environments per ticket, customer, or agent run
- Secure "open in browser" sandboxes for demos, support, and onboarding
- Multi-tenant workspaces where each session gets an isolated service container

## Dependencies for Background Agent Hosting

### Deployment Dependencies
- Railway API token + Project/Environment IDs (to create/delete sandbox services)
- GitHub personal acceses token (to clone the target repo and create branches/PRs)

## Why Deploy Background Agent 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 Background Agent on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


## 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/background-agent
