---
title: "Deploy OpenHands Coding Agent"
description: "Self-hosted autonomous AI engineer. Open-source, model-agnostic, free"
category: "AI/ML"
url: https://railway.com/deploy/openhands-coding-agent
---

# Deploy OpenHands Coding Agent

Self-hosted autonomous AI engineer. Open-source, model-agnostic, free

**[Deploy OpenHands Coding Agent on Railway](https://railway.com/template/openhands-coding-agent)**

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

## Template content

### OpenHands https://cdn.jsdelivr.net/gh/selfhst/icons/svg/openhands.svg

- **Source:** praveen-ks-2001/openhands-railway
- **Public domain:** Yes

## Documentation

# Deploy and Host OpenHands Coding Agent on Railway

![OpenHands](https://opengraph.githubassets.com/4a3fa291732195ae8467266dd5a49902a29d66a2efa92dcdd854c9c7a7e035f3/OpenHands/OpenHands)

**Self-host the open-source alternative to Devin — no $500/month subscription, no vendor lock-in,
no per-seat fees.**

OpenHands is the leading open-source autonomous AI software engineer with **70k+ GitHub stars**,
$18.8M in funding, and an MIT license. It writes code, runs terminal commands, browses the web,
and opens pull requests — all inside a sandboxed environment — using whatever LLM you bring.

---

## What This Template Deploys

| Service | Purpose |
|---|---|
| **OpenHands Agent Runtime** | Browser-accessible web UI where you assign tasks and review agent actions |
| **Sandboxed Docker Environment** | Isolated container for safe code execution, terminal commands, and web browsing |
| **Persistent Volume** | Retains workspace files, session history, and config across redeploys |

![OpenHands Dashboard](https://res.cloudinary.com/asset-cloudinary/image/upload/v1776595971/openhands_dashboard_ltl7nw.png)
---
## Deploy in Under 5 Minutes

1. Click **Deploy on Railway** and wait for the initial build (~3–5 minutes)
2. Add a persistent volume mounted at `/workspace` in Railway service settings
3. Set `LLM_MODEL` and `LLM_API_KEY` in the Variables tab
4. Open your Railway URL — the OpenHands web UI is live

No terminal. No SSH. No server configuration.

---

## Configuration

| Variable | Required | Description |
|---|---|---|
| `LLM_MODEL` | ✅ Yes | Model string — e.g. `anthropic/claude-sonnet-4-20250514` or `openai/gpt-4o` |
| `LLM_API_KEY` | ✅ Yes | API key for your LLM provider |
| `SANDBOX_RUNTIME_CONTAINER_IMAGE` | ✅ Yes | Use `docker.all-hands.dev/all-hands-ai/runtime:0.17-nikolaik` |
| `LOG_ALL_EVENTS` | Recommended | Set to `true` — enables full agent action logging |
| `LLM_BASE_URL` | Optional | OpenAI-compatible endpoint for Ollama, vLLM, or OpenRouter |
| `WORKSPACE_BASE` | Pre-set | Agent workspace path — should match your volume mount |
| `SANDBOX_USER_ID` | Optional | UID for sandbox process isolation |

> `PORT` is auto-injected by Railway. Docker socket access (`/var/run/docker.sock`) must be
> enabled on the service for the sandbox to start.

---

## Common Use Cases

- **Self-hosted alternative to Devin** — autonomous AI engineer on your own infrastructure for
  the cost of your API usage, not $500/month
- **Autonomous GitHub issue resolution** — assign an issue URL, receive a pull request; the agent
  reads context, writes the fix, and runs tests
- **Full-stack feature development** — describe a feature in plain English, get scaffolded and
  tested code across frontend and backend
- **Codebase refactoring at scale** — automate legacy migrations, lint fixes, TypeScript
  conversions, and dependency bumps across multiple repos
- **Shared team AI engineer** — one Railway deployment accessible to your whole team via browser,
  no per-seat licensing

---

## Frequently Asked Questions

**How much does it cost to run OpenHands on Railway?**
The Railway container itself runs at roughly $5–15/month on the Hobby plan. LLM API costs are
separate — no per-seat fees, no subscriptions beyond Railway's base compute.

**Is my code private?**
Yes. Everything stays on your Railway instance. API keys are stored as encrypted Railway secrets.
The agent sandbox is isolated and cannot access infrastructure outside the mounted workspace volume.

**Do I lose my workspace on redeploy?**
No. All workspace files and session history live on the persistent volume, not inside the
container. Redeploys and version updates do not touch your data.

**What LLM gives the best results?**
Claude Sonnet 4 (Anthropic) is recommended — OpenHands resolves 53%+ of SWE-bench verified issues
with it. GPT-4o is a strong alternative. For cost-sensitive work, GPT-4o-mini or Gemini Flash work
for simpler tasks.

**Can I use a local LLM?**
Yes, via any OpenAI-compatible endpoint — set `LLM_BASE_URL` to your Ollama or vLLM endpoint.
Check the OpenHands docs for models that support tool calling, which OpenHands requires.

**How do I update to a newer version?**
Update the Docker image tag in Railway service settings (e.g. `all-hands-ai/openhands:1.6.0`) and
redeploy. Your volume data is unaffected.

---

## OpenHands vs. Alternatives

| | OpenHands | Devin | GitHub Copilot Agent | Claude Code |
|---|---|---|---|---|
| **Open source** | ✅ MIT | ❌ Closed | ❌ Closed | ❌ Closed |
| **Self-hostable** | ✅ Yes | ❌ No | ❌ No | ❌ No |
| **Model agnostic** | ✅ Any LLM | ❌ Proprietary | ⚠️ Limited | ❌ Anthropic only |
| **Pricing** | Free (BYO key) | ~$500/mo | $10–$39/mo | API usage only |
| **Browser automation** | ✅ Yes | ✅ Yes | ❌ No | ❌ No |
| **PR creation** | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes |
| **Deployment** | Self-hosted | SaaS only | GitHub-hosted | Local terminal only |

---

## Why Deploy OpenHands 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 OpenHands on Railway, you get a production-ready autonomous AI engineer with
persistent storage, automatic HTTPS, Docker sandbox support, and zero server administration — at
the cost of your API usage alone.

---

## Resources

- [OpenHands GitHub Repository](https://github.com/OpenHands/OpenHands)
- [OpenHands Documentation](https://docs.all-hands.dev)
- [Supported LLM Providers](https://docs.all-hands.dev/usage/llms/llms)
- [Railway Volumes Documentation](https://docs.railway.com/volumes)
- [Anthropic API Keys](https://console.anthropic.com/)
- [OpenRouter](https://openrouter.ai/) — unified API for multiple providers

## 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/openhands-coding-agent
