Railway

Deploy SpacetimeDB 2.0

A performant real-time backend framework and database for apps and games.

Deploy SpacetimeDB 2.0

Just deployed

/stdb

Deploy and Host SpacetimeDB 2.0 on Railway

SpacetimeDB 2.0 is a realtime database/server designed for modern app backends. It combines persistence, realtime subscriptions, and server-side logic so clients can sync state instantly. With 2.0, it’s intended not just for games, but also for web apps that need live data and low-latency interactions.

About Hosting SpacetimeDB 2.0

Hosting SpacetimeDB 2.0 on Railway is straightforward: run the official Docker image, expose the HTTP/WebSocket API through a Railway HTTP Proxy, and mount a persistent volume for the node’s data directory. Your service must bind to 0.0.0.0 and listen on the port Railway routes to (commonly $PORT). For durability across deploys/restarts, mount a Railway Volume at /stdb and point the server at /stdb/data. For monitoring, add an HTTP healthcheck against /v1/ping.

Common Use Cases

  • Realtime web apps (collaboration, dashboards, presence, live feeds) with subscriptions and instant updates
  • Multiplayer/stateful experiences (lobbies, game state, matchmaking) with authoritative server logic
  • Event-driven backends (live notifications, sync engines) where clients react to state changes in realtime

Dependencies for SpacetimeDB 2.0 Hosting

  • Railway Volume for persistence (mount to /stdb)

Deployment Dependencies

Implementation Details

Recommended Railway settings

  • Docker Image: clockworklabs/spacetime:2.0.1 (pin to a 2.x tag)
  • Volume mount path: /stdb
  • Proxy: HTTP Proxy to your service
  • Healthcheck path: /v1/ping

Start command (recommended: bind to Railway’s ${PORT})

spacetime start --data-dir=/stdb/data --listen-addr 0.0.0.0:${PORT}

You can change the port in the service's env var.

Notes

  • SpacetimeDB’s primary interface is HTTP + WebSocket on the same port; an HTTP Proxy is the correct choice for most deployments.
  • The Postgres wire protocol is disabled by default; only add a TCP proxy (e.g., 5432) if you explicitly enable that listener.

Why Deploy SpacetimeDB 2.0 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 SpacetimeDB 2.0 on Railway, you are one step closer to supporting a complete full-stack application with minimal burden. Host your servers, databases, AI agents, and more on Railway.


Template Content

More templates in this category

View Template
Postgres Backup to Cloudflare R2 (S3-Compatible)
Automated PostgreSQL backups to S3-compatible storage with encryption

Aman
View Template
ReadySet
A lightweight caching engine for Postgres

Milo
View Template
Simple S3
Deploy a S3-compatible storage service with a pre-named bucket.

Joey Chilson