Deploy NATS

NATS 2.15 messaging server with JetStream, WebSocket and token auth.

Deploy NATS

Just deployed

/data

Deploy and Host NATS on Railway

NATS is a high-performance messaging system for services, devices and browsers. It provides publish/subscribe, request/reply and, with JetStream, persistent streams, key-value and object stores. Client libraries exist for Go, Rust, Node.js, Python, Java, .NET, C and more, and browsers connect over WebSocket. The server is a single small binary.

About Hosting NATS

This template deploys NATS Server v2.15.0 with JetStream enabled and stored on a Railway volume, so streams survive restarts. Clients authenticate with a generated token. Services on Railway connect over the private network on port 4222, external clients use the Railway TCP proxy, and browsers or serverless clients use WebSocket on the public HTTPS domain. The monitoring endpoint answers the health check privately. The config lives in the NATS_CONFIG variable, so accounts, users or limits can be changed without a custom image. Watch JetStream disk use on the Hobby plan.

Common Use Cases

  • Event streaming and work queues between microservices with JetStream
  • Real-time messaging to browsers and mobile apps over WebSocket
  • Lightweight request/reply RPC between services on Railway

Dependencies for NATS Hosting

  • nats:2.15.0-alpine (official image)
  • A Railway volume at /data for JetStream
  • A Railway TCP proxy for external client connections

Deployment Dependencies

Implementation Details

ServiceImageNetworkingStorage
natsnats:2.15.0-alpineprivate 4222; TCP proxy to 4222; public WebSocket on 8080volume at /data

Connection URLs:

NATS_URL=${{nats.NATS_URL}}                          # nats://@nats.railway.internal:4222
NATS_WEBSOCKET_URL=${{nats.NATS_WEBSOCKET_URL}}      # wss://, pass the token in the client options

External: nats://@:.

VariableDefaultPurpose
NATS_TOKENgeneratedClient authentication token
NATS_JETSTREAM_MAX_FILE4GJetStream disk limit; keep below your volume size
NATS_CONFIGserver configFull nats-server.conf, reads $NATS_* variables

Notes:

  • The TCP proxy carries plain NATS without TLS; prefer WebSocket over HTTPS or the private network for sensitive data, or add TLS in NATS_CONFIG.
  • Lame duck mode (30 s) and a 35 s draining window let clients move off cleanly during redeploys.

This is a community-maintained deployment package and does not imply affiliation with or endorsement by the NATS project or its maintainers.

Why Deploy NATS 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 NATS 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
smoothmq
A drop-in replacement for AWS SQS

poundifdef
7
View Template
Kafka UI
Kafbat UI — Open-source web UI to monitor and manage Apache Kafka clusters

codestorm
0
View Template
NEW
NATS + JetStream
An open source messaging system that promises at-most-once delivery.

Brayan Castaneda
1