---
title: "Deploy Centrifugo"
description: "Centrifugo 6.9 real-time WebSocket/SSE messaging server with Redis engine."
category: "Queues"
url: https://railway.com/deploy/centrifugo-1
---

# Deploy Centrifugo

Centrifugo 6.9 real-time WebSocket/SSE messaging server with Redis engine.

**[Deploy Centrifugo on Railway](https://railway.com/template/centrifugo-1)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/centrifugo-1/manifest.json

- **Creator:** Agaz Self-Host
- **Category:** Queues

## Template content

### centrifugo https://raw.githubusercontent.com/centrifugal/centrifugal.dev/baf647351d92fd7f43f2e85f65e3447c2127c8a8/static/img/favicon.png

- **Image:** centrifugo/centrifugo:v6.9.6
- **Health check:** /health
- **Public domain:** Yes

### Redis https://cdn.sanity.io/images/sy1jschh/production/0ce0bfdcfbdbf69662b1116671f97c2dd788b655-157x157.svg

- **Image:** redis:8.2
- **Start command:** `/bin/sh -c "rm -rf $RAILWAY_VOLUME_MOUNT_PATH/lost+found/ && exec docker-entrypoint.sh redis-server --requirepass $REDIS_PASSWORD --save 60 1 --dir $RAILWAY_VOLUME_MOUNT_PATH"`

## Documentation

# Deploy and Host Centrifugo on Railway

Centrifugo is an open-source, scalable real-time messaging server. Browser and mobile clients subscribe to channels over WebSocket, SSE or HTTP streaming, and your backend publishes to them through a simple HTTP API. You can use it for chat, live notifications, dashboards, multiplayer features and streaming AI responses, with any backend language.

## About Hosting Centrifugo

This template deploys Centrifugo v6.9.6 with a Railway Redis database as its engine. Because the engine is Redis, channel history survives restarts and you can run several Centrifugo replicas behind Railway's load balancer. Clients connect to the public domain at `/connection/websocket` using a JWT that your backend signs with the generated HMAC secret. Your backend publishes over the private network with the generated API key. The admin web UI is enabled on the public domain and protected by a generated password. Centrifugo is stateless and light, so the Hobby plan is enough. Before going to production, set the allowed origins to your frontend's domain.

## Common Use Cases

- Live chat, comments and notifications for web and mobile apps
- Real-time dashboards and activity feeds pushed from any backend (Node.js, Python, Go, PHP, Ruby, and others)
- Streaming LLM responses or job progress to many connected users

## Dependencies for Centrifugo Hosting

- `centrifugo/centrifugo:v6.9.6` (official image)
- Railway Redis (`redis:8.2`) with a volume, used as the Centrifugo engine
- A backend that signs connection JWTs and calls the Centrifugo HTTP API

### Deployment Dependencies

- [Centrifugo documentation](https://centrifugal.dev/docs/getting-started/introduction)
- [Centrifugo v6.9.6 release notes](https://github.com/centrifugal/centrifugo/releases/tag/v6.9.6)
- [Client SDKs](https://centrifugal.dev/docs/transports/client_sdk)
- [Railway private networking](https://docs.railway.com/reference/private-networking)

### Implementation Details

| Service | Image | Networking | Storage |
| --- | --- | --- | --- |
| centrifugo | `centrifugo/centrifugo:v6.9.6` | public domain on port 8000; private API | none |
| Redis | Railway Redis 8.2 | private only | volume |

Useful variables to reference from your backend service:

```env
CENTRIFUGO_API_URL=${{centrifugo.CENTRIFUGO_API_URL}}
CENTRIFUGO_API_KEY=${{centrifugo.CENTRIFUGO_HTTP_API_KEY}}
CENTRIFUGO_TOKEN_SECRET=${{centrifugo.CENTRIFUGO_CLIENT_TOKEN_HMAC_SECRET_KEY}}
CENTRIFUGO_WEBSOCKET_URL=${{centrifugo.CENTRIFUGO_WEBSOCKET_URL}}
```

Publish from your backend:

```bash
curl -X POST "$CENTRIFUGO_API_URL/publish" -H "X-API-Key: $CENTRIFUGO_API_KEY" \
  -d '{"channel": "news", "data": {"text": "hello"}}'
```

Connect from the browser with `centrifuge-js`, using an HS256 JWT (with `sub` set to the user ID) signed by your backend with `CENTRIFUGO_TOKEN_SECRET`:

```js
const client = new Centrifuge(CENTRIFUGO_WEBSOCKET_URL, { token });
client.newSubscription("news").on("publication", (ctx) => console.log(ctx.data)).subscribe();
client.connect();
```

| Variable | Default | Purpose |
| --- | --- | --- |
| `CENTRIFUGO_CLIENT_TOKEN_HMAC_SECRET_KEY` | generated secret | Verifies client connection JWTs |
| `CENTRIFUGO_HTTP_API_KEY` | generated secret | Required for the server API |
| `CENTRIFUGO_ADMIN_PASSWORD` | generated secret | Admin web UI login at the public domain |
| `CENTRIFUGO_CLIENT_ALLOWED_ORIGINS` | `*` | Set to your frontend origin(s), space-separated, for production |
| `CENTRIFUGO_CHANNEL_WITHOUT_NAMESPACE_*` | subscribe allowed for authenticated clients, history of 100 messages for 5 minutes, recovery on | Default channel behaviour |

Notes:

- Anonymous connections are not allowed. Every client needs a valid JWT, and clients cannot publish directly (only your backend, through the API).
- The allowed origins default to `*` so the template works on first deploy. Because connections are authenticated with JWTs rather than cookies, this is lower risk, but restrict it to your domains in production.
- Add channel namespaces, presence, or subscription tokens with more `CENTRIFUGO_*` environment variables. Run `centrifugo defaultenv` in the image to list them all.
- To disable the admin UI, set `CENTRIFUGO_ADMIN_ENABLED=false`.

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

## Why Deploy Centrifugo 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 Centrifugo 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.


## Similar templates

- [smoothmq](https://railway.com/deploy/AJv-64) — A drop-in replacement for AWS SQS
- [Kafka UI](https://railway.com/deploy/kafka-ui) — Kafbat UI — Open-source web UI to monitor and manage Apache Kafka clusters
- [NATS + JetStream](https://railway.com/deploy/nats-jetstream) — An open source messaging system that promises at-most-once delivery.

Open this page in a browser: https://railway.com/deploy/centrifugo-1
