🚂PaaS

Self-Host OpenClaw on Railway

Deploy OpenClaw on Railway with one click. The simplest self-hosting option with persistent storage, automatic builds, and zero terminal commands required.

Difficulty: beginnerTime: ~10 minCost: ~$5-10/mo

Self-Host OpenClaw on Railway

Railway is the fastest path from zero to a running OpenClaw instance. Its template system handles the Docker build, environment configuration, and deployment in a single flow, entirely through the browser. If you want self-hosted OpenClaw without touching a terminal, this is the guide for you.

Quick Path

For users who just want to get moving:

  1. Click the OpenClaw deploy template link (or deploy from the GitHub repo)
  2. Add a Volume mounted at /data in the Railway dashboard
  3. Set environment variables: OPENCLAW_GATEWAY_PORT, OPENCLAW_GATEWAY_TOKEN, OPENCLAW_STATE_DIR, OPENCLAW_WORKSPACE_DIR
  4. Enable the HTTP proxy on port 8080
  5. Access OpenClaw at your Railway-provided domain

Total time: under 10 minutes, no terminal required.

Prerequisites

No local tools, CLI installations, or Docker knowledge are needed.

Step 1: Deploy the Template

Railway templates are pre-configured deployment blueprints. Click the deploy button to start:

Deploy on Railway
Deploy on Railway

If the template link above does not work, you can deploy directly from the GitHub repository:

  1. Log in to railway.app
  2. Click New Project on your dashboard
  3. Select Deploy from GitHub repo
  4. Connect your GitHub account if prompted
  5. Search for or paste the OpenClaw repository URL
  6. Click Deploy

Railway detects the Dockerfile in the repository, builds the image, and starts the service. The initial build takes 2-4 minutes.

Step 2: Add a Persistent Volume

Without a volume, all OpenClaw data (sessions, configuration, workspace files) is lost on every redeployment. Adding a volume is essential.

  1. In your Railway project, click on the OpenClaw service
  2. Go to the Settings tab
  3. Scroll to the Volumes section
  4. Click Add Volume
  5. Set the mount path to /data
  6. Click Save

Railway provisions the volume and redeploys the service with the mount active. The default volume size is 1 GB, which is sufficient for most use cases. You can increase it later through the dashboard.

Step 3: Set Environment Variables

Click on your OpenClaw service, go to the Variables tab, and add the following:

VariableValueDescription
OPENCLAW_GATEWAY_PORT8080Port the gateway listens on (Railway expects 8080)
OPENCLAW_GATEWAY_TOKENyour-secure-tokenAuthentication token for accessing OpenClaw
OPENCLAW_STATE_DIR/data/.openclawWhere OpenClaw stores its internal state
OPENCLAW_WORKSPACE_DIR/data/workspaceWorking directory for code operations
ANTHROPIC_API_KEYsk-ant-...Your Anthropic API key
NODE_ENVproductionEnables production optimizations

To generate a secure gateway token, use any random string generator. A simple option:

openssl rand -hex 32

Or use an online generator if you prefer not to use the terminal.

After adding all variables, Railway automatically redeploys the service with the new configuration.

Variable Tips

Step 4: Enable the HTTP Proxy

Railway needs to know which port your service listens on to route public traffic to it.

  1. In your service's Settings tab, scroll to Networking
  2. Under Public Networking, click Generate Domain to get a *.railway.app domain
  3. Ensure the port is set to 8080 (matching OPENCLAW_GATEWAY_PORT)

Railway handles TLS termination automatically. Your service gets a free *.railway.app subdomain with HTTPS.

Step 5: Access OpenClaw

Once the deployment is complete and the health checks pass, access OpenClaw at:

https://your-service-name.railway.app/openclaw

Find your exact URL in the service's Settings tab under Domains.

You will need to authenticate using the gateway token you set in Step 3. The exact authentication method depends on your OpenClaw version, but typically involves passing the token as a header or query parameter on your first connection.

Understanding the Architecture

Railway's deployment model is straightforward:

Browser → Railway Edge (TLS) → Your Container (:8080) → OpenClaw
                                      ↓
                                 Volume (/data)
                                   ├── .openclaw/  (state)
                                   └── workspace/  (code)

Persistent Storage Details

The volume at /data is the backbone of your deployment's durability:

Creating Backups

From a machine with the Railway CLI installed:

# Install the Railway CLI if needed
npm install -g @railway/cli

# Login
railway login

# Link to your project
railway link

# Run a backup command inside the container
railway run openclaw backup create

Or through the Railway dashboard, use the Shell tab on your service to run:

openclaw backup create

Backup files are written to the volume at /data/.openclaw/backups/. Download them through the Railway shell or by adding a temporary file-serving route.

Updating OpenClaw

If deployed from a GitHub repo:

Push to the connected branch and Railway rebuilds automatically:

cd openclaw
git pull origin main
git push

Railway detects the push, builds the new Docker image, and performs a zero-downtime deployment.

If deployed from the template:

  1. Go to your service in the Railway dashboard
  2. Click the Settings tab
  3. Under Source, click Check for Updates or manually trigger a redeploy

Manual redeploy:

In the dashboard, click the Deployments tab and click Redeploy on the latest deployment.

Security Best Practices

Troubleshooting

Deployment stuck in "Building"

Railway builds Docker images remotely. If the build hangs for more than 10 minutes:

  1. Check the build logs in the Deployments tab for error messages
  2. Verify the Dockerfile exists in the repository root
  3. Try a manual redeploy from the dashboard

If the issue persists, Railway's build infrastructure may be experiencing an outage. Check status.railway.app.

"Port scan timeout" or service not reachable

This means Railway cannot detect your service listening on the expected port:

  1. Verify OPENCLAW_GATEWAY_PORT is set to 8080
  2. Check that the service's networking configuration matches this port
  3. Look at runtime logs for startup errors (missing environment variables, crash on boot)

A common mistake is setting the port variable but not having the application actually bind to that port. OpenClaw uses OPENCLAW_GATEWAY_PORT to determine its listen port.

Volume data not persisting

If data disappears between deploys:

  1. Confirm the volume is attached: go to Settings > Volumes and verify the mount path is /data
  2. Check that OPENCLAW_STATE_DIR points to a subdirectory of the volume mount (/data/.openclaw, not /app/.openclaw)
  3. If you recently attached the volume, you may need to redeploy for the mount to take effect

Out of memory crashes

Railway's default memory limit is generous, but heavy OpenClaw workloads can exceed it. Check for OOM events in the Deployments tab. To address this:

  1. Add a NODE_OPTIONS environment variable: --max-old-space-size=1536
  2. If the issue persists, upgrade your Railway plan for higher resource limits
  3. Consider splitting heavy workloads across multiple sessions

Cannot access the Railway shell

The in-browser shell requires a running deployment. If the service is crashing on startup, the shell will not be available. In this case:

  1. Check the deployment logs to identify the crash reason
  2. Fix any misconfigured environment variables
  3. Trigger a redeploy
  4. Try the shell again once the deployment is healthy

Cost Breakdown

Railway pricing is usage-based after the base plan fee:

ComponentCost
Hobby plan base$5/month
Compute (~0.5 vCPU, ~512 MB avg)~$2-5/month
Volume (1 GB)~$0.25/month
BandwidthIncluded in plan
TLS certificateIncluded
Total (Hobby plan)~$7-10/month

The Pro plan ($20/month base) includes higher resource limits and team features. For individual self-hosting, the Hobby plan is sufficient.

Railway provides a usage dashboard showing real-time cost tracking, so you can monitor exactly how much your deployment costs and adjust resources accordingly.

Frequently Asked Questions

Do I need any terminal or command-line experience to deploy on Railway?

No. Railway's template deployment is entirely browser-based. You click the deploy button, fill in environment variables through the web UI, attach a volume through the dashboard, and access OpenClaw through the generated Railway domain. The entire process requires zero terminal commands.

How much does Railway cost for running OpenClaw?

Railway charges based on resource usage. A typical OpenClaw deployment uses about 0.5-1 vCPU and 512 MB-1 GB RAM, which costs roughly $5-10/month on the Pro plan ($5/month base fee, then usage-based billing). The Hobby plan ($5/month) also works for light usage.

Will my data survive redeployments on Railway?

Yes, as long as you attach a Volume. The volume at /data persists independently of the container. When Railway rebuilds and redeploys your service (from a git push or manual redeploy), the new container mounts the same volume with all your existing data intact.

Can I use a custom domain with Railway?

Yes. In the Railway dashboard, go to your service's Settings tab, find the Networking section, and add a custom domain. Railway provisions a TLS certificate automatically. Point your domain's CNAME record to the Railway-provided target.

How do I view logs for my OpenClaw deployment?

Click on your service in the Railway dashboard and select the Deployments tab. Click any deployment to see its build and runtime logs in real time. You can also use the Railway CLI with 'railway logs' if you prefer the terminal.

SuperBuilder

Prefer a managed experience?

SuperBuilder runs OpenClaw with zero setup — cloud execution, cost tracking, and team collaboration built in.

Try SuperBuilder Free