Platform setup
How to Deploy OpenClaw on Railway
Browse more in Platform setup.
All platform setup guides →This guide walks you through deploying OpenClaw on Railway using the official one-click template. You use Railway to host the OpenClaw Gateway and Control UI without managing a server shell.
By the end, you expose OpenClaw over HTTPS on your Railway domain with persistent storage and a shared secret protecting the gateway.
Prerequisites
- ✓A Railway account with permission to deploy services and attach a Volume.
- ✓Access to the OpenClaw Railway template at https://railway.com/deploy/clawdbot-railway-template.
- ✓An admin-grade secret you can use for OPENCLAW_GATEWAY_TOKEN.
- ✓A browser that can reach your Railway service domain (for the Control UI at /openclaw).
Steps
- 1
Deploy the OpenClaw template on Railway
Start from the official template so Railway wires up the container and default settings for you. This avoids manual Docker or build configuration and gives you a working Gateway and Control UI out of the box.
texthttps://railway.com/deploy/clawdbot-railway-template - 2
Attach a persistent Volume at /data
Attach a Railway Volume and mount it at /data so your OpenClaw state survives restarts and redeploys. Without this, config files, auth profiles, and workspace data reset every time the service rebuilds.
text/data - 3
Configure required OpenClaw variables
Set the OpenClaw-specific environment variables on the Railway service so the Gateway binds to the right port and knows where to store state. The token acts as an admin secret, so treat it like a password.
textOPENCLAW_GATEWAY_PORT=8080 OPENCLAW_GATEWAY_TOKEN OPENCLAW_STATE_DIR=/data/.openclaw OPENCLAW_WORKSPACE_DIR=/data/workspace - 4
Enable HTTP Proxy on port 8080
Expose the Gateway over HTTPS by enabling Railway's HTTP Proxy on the same port OpenClaw listens on. If the port numbers do not match, the Control UI at /openclaw will not be reachable from the internet.
textPort: 8080 - 5
Open the Control UI on your Railway domain
Once Railway deploys, grab the public URL from the service Domains page and append /openclaw. Use the shared secret you configured (OPENCLAW_GATEWAY_TOKEN by default) to connect to the gateway.
texthttps://<your-railway-domain>/openclaw - 6
Connect a messaging channel to your agent
Use the Control UI or Railway’s shell to run openclaw onboard and follow the channel-specific instructions. Starting with Telegram is fastest because it only needs a bot token.
bashopenclaw onboard - 7
Create backups for migration or recovery
Use the built-in backup command to export your state, config, auth profiles, and workspace into a portable archive. This makes it straightforward to migrate to another platform or restore after a mistake.
bashopenclaw backup create
Configuration
| Option | Description | Example |
|---|---|---|
| OPENCLAW_GATEWAY_PORT | Port the OpenClaw Gateway listens on inside the Railway service; must match the HTTP Proxy port. | 8080 |
| OPENCLAW_GATEWAY_TOKEN | Admin shared secret the Control UI uses to authenticate to the Gateway. | claw-admin-shared-secret-123 |
| OPENCLAW_STATE_DIR | Directory where OpenClaw stores gateway state, config, auth profiles, and sessions. | /data/.openclaw |
| OPENCLAW_WORKSPACE_DIR | Directory where OpenClaw stores workspace files that should persist across deploys. | /data/workspace |
Troubleshooting
You open https://<your-railway-domain>/openclaw and the page does not load.
Railway is likely not proxying the correct port. In your service Public Networking settings, enable HTTP Proxy and set the Port to 8080, then confirm OPENCLAW_GATEWAY_PORT=8080 in your variables so they match.
OPENCLAW_GATEWAY_PORT=8080After redeploying the Railway service, your agents, auth profiles, or workspace files are missing.
OpenClaw needs a Volume mounted at /data to persist state. openclaw and OPENCLAW_WORKSPACE_DIR=/data/workspace so state and workspace survive redeploys.
/dataFrequently asked questions
Powered by Mem0
Add persistent memory to OpenClaw
Official Mem0 plugin for OpenClaw keeps context across chats and tools. Smaller prompts, lower cost, better continuity for your agents.