OpenClaw LogoOpenClaw AI

Deploy OpenClaw on Railway: A Complete Guide

Claw
Deploy OpenClaw on Railway: A Complete Guide

What is OpenClaw?

OpenClaw (formerly Clawdbot / Moltbot) is an open-source self-hosted AI personal assistant framework. It can interact with you through chat platforms like Telegram, Discord, WhatsApp, and Slack, helping you manage emails, schedule events, execute code, browse the web, automate repetitive tasks, and more. You have full control over your data, and all information is kept on your own instance.

Why Choose Railway?

Railway is currently the easiest and most stable cloud-based method for deploying OpenClaw. Compared to renting a VPS or setting up Docker yourself, Railway's advantages include:

  • One-click deployment template: Strongly recommended in the official documentation (docs.openclaw.ai), with over 2000 production deployments from the community template.
  • Zero terminal operations: Configuration is entirely done through the in-browser /setup wizard, without typing a single command.
  • Built-in HTTPS and Domains: Railway automatically provisions a *.up.railway.app domain and SSL certificates, and supports custom domains as well.
  • Persistent storage: Your configuration and data are saved using Railway Volumes, meaning redeployments will not cause data loss.
  • Low cost: The free tier is enough for initial testing, and the Hobby plan starts around $5/month depending on traffic.

Prerequisites

Before you start, you need the following:

ItemDescription
Railway AccountRegister at . We strongly recommend logging in with GitHub. No credit card required to use the free tier.
AI Provider API KeyAt least one: Anthropic (Claude), OpenAI (GPT), Google Gemini, or OpenRouter (recommended for beginners as it offers free credits and low-cost model switching).
Chat Channel Token (Optional)Telegram Bot Token (from BotFather, easiest), Discord Bot Token, Slack App Token, etc.

Full Deployment Steps (Takes approx. 5–12 mins)

Step 1: Click the One-Click Deployment Template

Currently, the most used and recommended template paths are:

  • Official Document Link (Recommended): Go to https://railway.com/new/template/openclaw-railway-template and click the "Deploy on Railway" button on the page.
  • Mainstream Community Template: Search for "OpenClaw" or "Clawdbot" in the Railway template marketplace, and select a template with high deployments and active maintenance.

Clicking this will redirect you to the Railway interface. Press "Deploy Now" to begin.

Step 2: Set Variables

Railway will prompt you to enter required and recommended environment variables. The template includes hints; just follow them:

Variable NameSuggested Value / DescriptionRequired?
SETUP_PASSWORDSet a strong password (8-20 characters, must remember this, used for logging into the /setup wizard)Required
OPENCLAW_GATEWAY_TOKENA secure string (32+ chars, ideally generated by a password manager; the authentication key between the app and the Gateway)Required
PORT8080 (pre-configured in most templates, leave blank or 8080)Recommended
OPENCLAW_STATE_DIR/data/.openclaw (persistent path for configuration and credentials)Recommended
OPENCLAW_WORKSPACE_DIR/data/workspace (persistent path for your workspace)Recommended
ENABLE_WEB_TUItrue (enables the web terminal UI for easy debugging)Optional

Tip: Other variables like OPENAI_API_KEY, ANTHROPIC_API_KEY, GEMINI_API_KEY, etc. can be filled out later in the Setup Wizard. It's fine to skip them at this stage.

Step 3: Add Volume (Persistent Storage, Do Not Forget!)

This step is critical. Railway's container file system is ephemeral, and only mounted Volumes will retain data across restarts and redeployments.

How to do it:

  1. After deployment, go to your Service page.
  2. Find the Volumes section and click + New Volume.
  3. The Mount Path must be set to /data. This is where configuration files, long-term memory, and device pairing info will be stored.
  4. We recommend allocating 5GB of space (more than enough for personal use).
  5. After creation, click Redeploy to apply the Volume.

Warning: Without a Volume, every restart or Redeploy will wipe your settings, and you'll have to start from scratch.

Step 4: Enable Public Networking

In your Service settings:

  1. Go to Settings → Public Networking.
  2. Enable HTTP Proxy and set the port to 8080.
  3. Railway will automatically assign a domain (like https://<project-name>-production.up.railway.app), and you can also bind a custom domain here.

Copy and save this public URL; you'll need it for the next steps.

Step 5: Wait for Deployment to Finish

The Build and Deploy process usually takes 2-5 minutes. You can check the logs in Railway under Deployments → View Logs. When you see something like this, it's successfully running:

Step 6: Enter the Setup Wizard (Crucial Step)

Open your browser and navigate to:

OpenClaw Setup Wizard

The system will prompt you with an HTTP Basic Auth window:

  • Username: Type anything (like admin), it gets ignored.
  • Password: Enter the SETUP_PASSWORD you configured in Step 2.

After logging in, you'll be in the Setup Wizard. Follow the on-screen steps:

  1. Select LLM Provider: We suggest OpenRouter (free tier for testing), Anthropic, Google Gemini, or OpenAI.
  2. Enter API Key: Paste the provider's API Key. If you don't have one, register at to get free credits for testing different models like Claude, Gemini, and Llama.
  3. Bind Chat Channel (Optional but recommended): Telegram is simplest—get a Bot Token from BotFather. Discord requires checking bot and applications.commands scopes in the OAuth2 URL Generator before inviting the bot.
  4. Enter Gateway Token: Input the OPENCLAW_GATEWAY_TOKEN you set in Step 2.
  5. Additional Options: You can leave browser tools, filesystem access, etc., on their default values for now.
  6. Click Run Setup / Save. Wait 10-30 seconds until it shows success.

Step 7: Device Pairing and Getting Started

  1. Use Telegram (or your configured app) to find your Bot and send any message (like hi or /start).
  2. The Bot will reply with "Pairing Required".
  3. Return to your browser and open https://YourRailwayDomain/openclaw (or the root URL).
  4. In the Control UI, find the Pending Devices list and click Approve for your device.
  5. Send another message, and you can now interact with your AI normally!

Useful URLs After Deployment

URLPurpose
https://YourDomain/setupSetup Wizard (password protected) for config modifications and backups
https://YourDomain/openclawControl UI Dashboard for device management and chat logs
https://YourDomain/tuiWeb Terminal UI (Requires ENABLE_WEB_TUI=true)

Common Issues & Troubleshooting

"Internal error" or "Gateway did not become ready"

Wait 1-2 minutes and try again. If it persists, click Redeploy in Railway. Check the logs for clear error formatting (e.g. invalid API keys).

Control UI shows "gateway disconnected" or Authentication Errors

Do not visit /openclaw directly right away. Open /setup first, and click the "Open OpenClaw UI" button there. The Setup page passes the authentication token to the UI; skipping it results in a missing token and connection failure.

"Pairing required" or "Disconnected (1008)"

Go to https://YourDomain/setup, and in the Devices area manually click "Manage Devices" or "Approve Latest Request". Ensure the Gateway Token is entered correctly (case-sensitive).

Switching AI Models

You can switch models using the OpenClaw CLI. If Web TUI is enabled, run in /tui:

Alternatively, return to /setup to update the provider and API key, then run Setup again.

Configuration Seems Corrupted or Strange Errors

Go to /setup and click the "Run Doctor" button. This executes openclaw doctor --repair, which performs a health check, backs up your setting, and removes unrecognized or broken configurations.


Cost Estimation

ItemCost
RailwayFree tier is sufficient for testing; Hobby tier starts around $5/month.
LLM InferenceCan start near zero with OpenRouter's free models; paid models like Claude Sonnet bill based on usage.

Advanced Operations

Accessing the Container Shell

If you need to run terminal commands:

  • Web TUI: Deploy with ENABLE_WEB_TUI=true and visit /tui.
  • Railway CLI: Install the Railway CLI locally, connect using railway link, and use railway shell to enter the container.

Backups and Migration

  • Manual Backup: Go to /setup and click Export Backup (in .zip). You can restore this on any platform (VPS, Docker, Home Server).
  • Automated Backups: You can use rclone to periodically sync the /data directory to cloud storage.
  • Migrating Away: Export a backup .zip, deploy OpenClaw on the new platform, and import it. You are never locked into Railway.

Multi-Instance Deployment

You can deploy the template on Railway multiple times. Each instance gets its own domain, Volume, and configuration, making it easy to separate personal and work usage.


Summary

The entire workflow to deploy OpenClaw on Railway comprises five key steps: Click Template → Set Variables → Mount Volume → Enable Public Networking → Complete Setup Wizard. It's done entirely in the browser. If you hit any snags, reviewing Railway's deploy logs usually points you right to the issue. *