---
title: "Deploy Zero Sync | (Just Updated) Realtime Sync Engine for Postgres, Secrets Generated"
description: "Zero sync engine plus Postgres, logical replication and secrets generated"
category: "Queues"
url: https://railway.com/deploy/zero-sync-or-just-updated-realtime-sync-
---

# Deploy Zero Sync | (Just Updated) Realtime Sync Engine for Postgres, Secrets Generated

Zero sync engine plus Postgres, logical replication and secrets generated

**[Deploy Zero Sync | (Just Updated) Realtime Sync Engine for Postgres, Secrets Generated on Railway](https://railway.com/template/zero-sync-or-just-updated-realtime-sync-)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/zero-sync-or-just-updated-realtime-sync-/manifest.json

- **Creator:** SuperSlowSloth
- **Category:** Queues

## Template content

### postgres

- **Image:** postgres:18.6@sha256:74935e72241653ca55e0414067e6d8763aceb8a810eb51b452253ec3dcfc4336
- **Start command:** `/bin/sh -c 'printf "CREATE TABLE IF NOT EXISTS public.todos (id serial PRIMARY KEY, task text NOT NULL, done boolean NOT NULL DEFAULT false);\nINSERT INTO public.todos (task) SELECT chr(104)||chr(101)||chr(108)||chr(108)||chr(111);\n" > /docker-entrypoint-initdb.d/00-zero.sql; exec docker-entrypoint.sh postgres -c wal_level=logical -c max_wal_senders=20 -c max_replication_slots=20'`

### zero-cache

- **Image:** rocicorp/zero@sha256:893c4a78a1a84f1ab8d7e76263b4bab3c8aee61101b00b365756c47e328935a2
- **Start command:** `/bin/sh -c 'export ZERO_PORT=$PORT ZERO_REPLICA_FILE=/data/replica.db ZERO_ENABLE_CRUD_MUTATIONS=true ZERO_ALLOW_LEGACY_QUERIES=true; exec zero-cache'`
- **Health check:** /keepalive
- **Public domain:** Yes

## Documentation

# Deploy and Host Zero on Railway

Zero is the open-source sync engine from Rocicorp. It sits in front of Postgres, replicates the tables you choose into a SQLite replica, and streams query results to web and mobile clients over WebSocket, so apps read and write instantly and stay in sync. This template deploys zero-cache 1.11 together with a Postgres 18 database that is already configured for logical replication. Passwords are generated for you, so nothing needs filling in.

## About Hosting Zero

The template runs two services. `postgres` is the official Postgres 18 image started with `wal_level=logical` (Zero requires it) and seeded with a small `public.todos` table. `zero-cache` is the official `rocicorp/zero` image pinned by digest; it connects to Postgres over the private network, creates its publication and replication slot on first boot, and keeps its replica on a volume at `/data`. Health is `GET /keepalive`.

## Why Deploy Zero on Railway?

- No manual step: Postgres is pre-configured for logical replication and both passwords are generated.
- Public HTTPS and WSS endpoint with the health path wired up.
- The Postgres data and the Zero replica both sit on volumes, so a redeploy keeps them.
- Legacy queries and CRUD mutations are enabled, so a client can connect with only a schema.

## Common Use Cases

- Local-first and instant-UI web apps that read from a synced local cache.
- Multiplayer apps where several clients and AI agents see the same data change live.
- Replacing hand-written REST polling and cache invalidation with query subscriptions.
- A self-hosted alternative to hosted sync services such as Convex or Firebase.

## Dependencies for Zero Hosting

### Deployment Dependencies

- Image: [rocicorp/zero](https://hub.docker.com/r/rocicorp/zero) (zero-cache 1.11.0), pinned by digest
- Database: Postgres 18 with `wal_level=logical`, volume at `/var/lib/postgresql`
- Docs: https://zero.rocicorp.dev/docs
- Replica volume mounted at `/data`

## Machine-readable contract

```
service: zero-cache
base_url: https://
health: GET /keepalive -&gt; 200
websocket: wss:///   (ZeroProvider server option = base_url)
credential_variables:
  ZERO_ADMIN_PASSWORD   (zero-cache; admin/inspector access)
  POSTGRES_PASSWORD     (postgres service)
connection_variables:
  ZERO_UPSTREAM_DB      (postgres://postgres:@:5432/postgres)
seed_table: public.todos (id, task, done)
volumes: /data (zero-cache replica), /var/lib/postgresql (postgres)
```

Check health:

```
curl https:///keepalive
```

Connect a client:

```js
import { Zero } from "@rocicorp/zero";
const z = new Zero({ server: "https://", userID: "anon", schema });
const todos = await z.query.todos.run();
```


## Similar templates

- [Celery | Web, Worker and Scheduler as Three Services](https://railway.com/deploy/celery-or-web-work-1) — Web, worker and scheduler wired up: Celery on Redis, outcomes in Postgres.
- [Redpanda](https://railway.com/deploy/redpanda-1) — Redpanda 26.2: Kafka-compatible streaming, single node, with Kafbat UI.
- [smoothmq](https://railway.com/deploy/AJv-64) — A drop-in replacement for AWS SQS

Open this page in a browser: https://railway.com/deploy/zero-sync-or-just-updated-realtime-sync-
