Deploy OpenHands Coding Agent
Self-hosted autonomous AI engineer. Open-source, model-agnostic, free
OpenHands
Just deployed
/.openhands
Deploy and Host OpenHands Coding Agent on Railway
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 |
Deploy in Under 5 Minutes
- Click Deploy on Railway and wait for the initial build (~3–5 minutes)
- Add a persistent volume mounted at
/workspacein Railway service settings - Set
LLM_MODELandLLM_API_KEYin the Variables tab - 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 |
PORTis 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
- OpenHands Documentation
- Supported LLM Providers
- Railway Volumes Documentation
- Anthropic API Keys
- OpenRouter — unified API for multiple providers
Template Content
OpenHands
sahilrupani/OpenHands