---
title: "Deploy Chartbrew"
description: "Build and share live dashboards from APIs, SQL, and NoSQL data"
category: "Analytics"
url: https://railway.com/deploy/chartbrew
---

# Deploy Chartbrew

Build and share live dashboards from APIs, SQL, and NoSQL data

**[Deploy Chartbrew on Railway](https://railway.com/template/chartbrew)**

- **Creator:** RBR Digital
- **Category:** Analytics
- **Total deploys:** 3

## Template content

### Postgres https://devicons.railway.app/i/postgresql.svg

- **Image:** ghcr.io/railwayapp-templates/postgres-ssl:18

### Chartbrew https://chartbrew.com/favicon.ico?favicon.0nwzf~4ob7ktg.ico

- **Image:** razvanilin/chartbrew:latest
- **Public domain:** Yes

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

- **Image:** redis:8.2.1
- **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"`

### Chartbrew Backend Proxy https://chartbrew.com/favicon.ico?favicon.0nwzf~4ob7ktg.ico

- **Source:** douglasrubims/railway-second-port
- **Public domain:** Yes

## Documentation

# Deploy and Host Chartbrew on Railway

Chartbrew is a reporting platform for building and sharing live dashboards from APIs, SQL, and NoSQL databases. Connect data sources, design charts and dashboards, schedule refreshes, and share insights with your team or embed charts in other products.

## About Hosting Chartbrew

This template deploys Chartbrew as a multi-service stack on Railway. Chartbrew runs in a single container with two endpoints: a **client UI** on port `4018` and an **API server** on port `4019`. Because Railway exposes one public port per domain, this template uses a **Second Port** proxy service to give the API its own public URL while the main Chartbrew domain serves the UI.

The stack includes **PostgreSQL** for data storage, **Redis** for queues and caching, and **Second Port** (Caddy) to forward public HTTPS traffic to the API over Railway's private network. On startup, Chartbrew migrates the database schema automatically. The API must bind to **`::`** and both Postgres and Redis must be reachable before the server logs `Running server on port 4019`.

## Common Use Cases

- Internal analytics dashboards fed by product APIs, SQL databases, or MongoDB
- Client-facing or embedded reporting for SaaS products
- Scheduled data refreshes and shareable dashboard links for teams and stakeholders

## Dependencies for Chartbrew Hosting

- **PostgreSQL** database (schema migrated automatically on startup)
- **Redis** for queues and caching
- **Second Port** proxy service to expose the API on a dedicated public domain
- A 32-byte **`CB_ENCRYPTION_KEY`** for encrypting stored credentials and tokens

### Deployment Dependencies

- [Chartbrew environment variables](https://docs.chartbrew.com/environment-variables)
- [Chartbrew Docker deployment guide](https://docs.chartbrew.com/deployment/run-on-docker)
- [Railway private networking](https://docs.railway.app/guides/private-networking)
- [Railway service variables](https://docs.railway.app/guides/variables)

### Implementation Details

This template wires four services together: **Chartbrew**, **Postgres**, **Redis**, and **Chartbrew Backend Proxy** (Second Port).

**How it works**

```
Internet
   │
   ├── https://chartbrew.up.railway.app ──────────► Chartbrew :4018 (UI)
   │
   └── https://chartbrew-backend-proxy.up.railway.app
              │
              ▼
       Second Port proxy :3000
              │  Railway private network
              ▼
       Chartbrew API :4019 (chartbrew.railway.internal)
```

The UI is served directly on the Chartbrew public domain (port **4018**). API requests from the browser go to the proxy's public domain, which forwards them to port **4019** on the Chartbrew container via private networking.

**Chartbrew service variables:**

```env
PORT="4019"
CB_API_HOST="::"
CB_API_PORT="${{PORT}}"
CB_DB_DIALECT="postgres"
CB_DB_HOST="${{Postgres.PGHOST}}"
CB_DB_NAME="${{Postgres.PGDATABASE}}"
CB_DB_PORT="${{Postgres.PGPORT}}"
CB_DB_USERNAME="${{Postgres.PGUSER}}"
CB_DB_PASSWORD="${{Postgres.PGPASSWORD}}"
CB_REDIS_HOST="${{Redis.REDISHOST}}"
CB_REDIS_PORT="${{Redis.REDISPORT}}"
CB_REDIS_PASSWORD="${{Redis.REDISPASSWORD}}"
CB_ENCRYPTION_KEY="${{ secret(64, \"0123456789abcdef\") }}"
VITE_APP_CLIENT_PORT="4018"
VITE_APP_CLIENT_HOST="https://${{RAILWAY_PUBLIC_DOMAIN}}"
VITE_APP_API_HOST="https://${{\"Chartbrew Backend Proxy\".RAILWAY_PUBLIC_DOMAIN}}"
VITE_APP_API_PORT="443"
```

- `PORT=4019` ensures the API listens on a fixed port inside the container.
- `CB_API_HOST=::` makes the API reachable over Railway's private network (required for the proxy).
- `VITE_APP_CLIENT_HOST` points the UI at the Chartbrew public domain.
- `VITE_APP_API_HOST` points the UI at the proxy's public domain so browser requests reach the API.

**Chartbrew Backend Proxy (Second Port) variables:**

```env
TARGET_DOMAIN="${{Chartbrew.RAILWAY_PRIVATE_DOMAIN}}"
TARGET_PORT="4019"
```

The proxy resolves the Chartbrew private hostname and forwards all traffic to port **4019**.

**Public domain configuration**

| Service | Public domain port |
|---------|-------------------|
| Chartbrew | **4018** (UI) |
| Chartbrew Backend Proxy | **3000** (API gateway) |

**Validation**

After deploy, confirm in the Chartbrew logs:

```
Running server on port 4019
```

Open the proxy public URL — it should respond with:

```
Welcome to chartBrew server API
```

Then open the Chartbrew public URL and verify the login page loads without "Failed to fetch" errors.

## Why Deploy Chartbrew 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 Chartbrew 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 Author

Created and maintained by **Douglas Rubim**.

GitHub: https://github.com/douglasrubims

## Similar templates

- [Betterlytics](https://railway.com/deploy/betterlytics) — Betterlytics is a cookieless analytics platform GDPR-compliant.
- [Finance Tracker](https://railway.com/deploy/finance-tracker-1) — Private multi-user household finance ledger with budgets and CSV import.
- [Matomo Analytics + MariaDB](https://railway.com/deploy/matomo-analytics-mariadb) — Privacy-friendly analytics with MariaDB and persistent volumes.

Open this page in a browser: https://railway.com/deploy/chartbrew
