Railway

Deploy OpenHands Coding Agent

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

Deploy OpenHands Coding Agent

Just deployed

/.openhands

Deploy and Host OpenHands Coding Agent on Railway

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

ServicePurpose
OpenHands Agent RuntimeBrowser-accessible web UI where you assign tasks and review agent actions
Sandboxed Docker EnvironmentIsolated container for safe code execution, terminal commands, and web browsing
Persistent VolumeRetains workspace files, session history, and config across redeploys

OpenHands Dashboard

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

VariableRequiredDescription
LLM_MODEL✅ YesModel string — e.g. anthropic/claude-sonnet-4-20250514 or openai/gpt-4o
LLM_API_KEY✅ YesAPI key for your LLM provider
SANDBOX_RUNTIME_CONTAINER_IMAGE✅ YesUse docker.all-hands.dev/all-hands-ai/runtime:0.17-nikolaik
LOG_ALL_EVENTSRecommendedSet to true — enables full agent action logging
LLM_BASE_URLOptionalOpenAI-compatible endpoint for Ollama, vLLM, or OpenRouter
WORKSPACE_BASEPre-setAgent workspace path — should match your volume mount
SANDBOX_USER_IDOptionalUID 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

OpenHandsDevinGitHub Copilot AgentClaude Code
Open source✅ MIT❌ Closed❌ Closed❌ Closed
Self-hostable✅ Yes❌ No❌ No❌ No
Model agnostic✅ Any LLM❌ Proprietary⚠️ Limited❌ Anthropic only
PricingFree (BYO key)~$500/mo$10–$39/moAPI usage only
Browser automation✅ Yes✅ Yes❌ No❌ No
PR creation✅ Yes✅ Yes✅ Yes✅ Yes
DeploymentSelf-hostedSaaS onlyGitHub-hostedLocal 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


Template Content

More templates in this category

View Template
Foundry Virtual Tabletop
A Self-Hosted & Modern Roleplaying Platform

Lucas
View Template
Letta Code Remote
Run a Letta Code agent 24/7. No inbound ports, just deploy.

Letta
View Template
(v1) Simple Medusa Backend
Deploy an ecommerce backend and admin using Medusa

Shahed Nasser