---
title: "Deploy Aptabase | (Just Updated) Privacy-First App Analytics, Dashboard Login And Ingestion Key Generated"
description: "Aptabase self-hosted app analytics, privacy-first, Postgres + ClickHouse"
category: "Analytics"
url: https://railway.com/deploy/aptabase-or-just-updated-privacy-first-a
---

# Deploy Aptabase | (Just Updated) Privacy-First App Analytics, Dashboard Login And Ingestion Key Generated

Aptabase self-hosted app analytics, privacy-first, Postgres + ClickHouse

**[Deploy Aptabase | (Just Updated) Privacy-First App Analytics, Dashboard Login And Ingestion Key Generated on Railway](https://railway.com/template/aptabase-or-just-updated-privacy-first-a)**

Machine-readable deploy manifest (JSON, validated by TemplateCI): https://railway.com/deploy/aptabase-or-just-updated-privacy-first-a/manifest.json

- **Creator:** SuperSlowSloth
- **Category:** Analytics

## Template content

### aptabase

- **Image:** ghcr.io/bon5co/aptabase-railway:main-61d4c01@sha256:a43cfb5b74d690f77762f1981ce61cc8fae675d88cd870886627200557fc8819
- **Health check:** /healthz
- **Public domain:** Yes

### database

- **Image:** postgres:16-alpine@sha256:1d5b02d3a9941fbd52437db4107f8c52d6297dac553ca1e5c299ebb3756b4857

### clickhouse

- **Image:** clickhouse/clickhouse-server:26.8.36.3-alpine@sha256:f5443f9ffa48f0154cdd50cab39fed732201762574a27f04f1f564bbba81832d
- **Start command:** `/bin/sh -c 'export CLICKHOUSE_USER=aptabase CLICKHOUSE_DEFAULT_ACCESS_MANAGEMENT=1; exec /entrypoint.sh'`

## Documentation

# Deploy and Host Aptabase on Railway

**Built for an LLM agent to deploy and use.** The deploy form has no fields to fill: the session secret, the ingestion key and the database passwords are generated, the dashboard owner and one app are created before the web server starts, and public sign-up is closed, so nobody can register on a fresh instance. Aptabase is the open-source, privacy-first analytics service for mobile, desktop and web apps: event ingestion with an SDK key, a dashboard, and no cookies or personal data collected.

## About Hosting Aptabase

This template runs three services: **aptabase**, the official `ghcr.io/aptabase/aptabase` image (the ASP.NET server plus the React dashboard) pinned by digest through a thin wrapper, with a volume at `/root/.aspnet` that holds the data-protection keys so dashboard sessions survive a redeploy; **database**, a PostgreSQL 16 instance with a volume at `/var/lib/postgresql` that holds users and apps; and **clickhouse**, a ClickHouse server with a volume at `/var/lib/clickhouse` that holds every event. One public domain serves the dashboard and the ingestion API. The server migrates both databases on boot, so allow a few minutes before the first request answers.

**What the wrapper fixes.** The stock image starts with no user and no app, signs people in only by an emailed magic link, leaves `/api/_auth/register` open to anyone, and answers HTTP 200 with an error body to an event that carries no `App-Key`, which a client cannot tell from success. The wrapper puts nginx on the injected `PORT` (Railway's healthcheck and edge dial it), creates the owner account from `ADMIN_EMAIL` and one app whose ingestion key is `APTABASE_APP_KEY` before it opens the port, answers 401 to an event with no `App-Key`, and answers 403 to sign-up. It also switches the console log to plain text: upstream's JSON console format reaches Railway's log viewer with an empty message, and the sign-in link is only ever logged. Not reproduced on a Railway control of an incumbent listing.

**Using it.** Send events with `POST /api/v0/event` (one) or `/api/v0/events` (a batch) and the header `App-Key: $APTABASE_APP_KEY`; point any Aptabase SDK at `https://RAILWAY_PUBLIC_DOMAIN` as its self-hosted host. To open the dashboard, enter `ADMIN_EMAIL` (default `admin@example.com`) on the sign-in page: no mail is sent, so read the sign-in link from the `aptabase` service's deploy log (`Sending email to ... with template 'SignIn'`) and open it. To change the owner address add an `ADMIN_EMAIL` variable on the `aptabase` service; to send the link by email add the SMTP variables from the upstream documentation. Everything is stored in PostgreSQL, ClickHouse and the volumes, so redeploys keep it.

### Agent contract

- Public URL: `https://RAILWAY_PUBLIC_DOMAIN` (the generated domain of the `aptabase` service)
- Private URL: `http://aptabase.railway.internal:8080`
- Credentials: the variables `APTABASE_APP_KEY` (the ingestion key, `A-SH-` plus 10 digits) and `AUTH_SECRET` on the `aptabase` service; add an `ADMIN_EMAIL` variable to change the dashboard owner address (default `admin@example.com`, not a template variable)
- Auth: send the header `App-Key: $APTABASE_APP_KEY` on every call under `/api/v0/`; the dashboard has no password, it signs in by a link that is written to the `aptabase` deploy log. An event with a wrong or unknown key is answered 200 with an error body by upstream, so confirm ingestion in the dashboard rather than by the status code alone
- Health: `GET /healthz` returns 200 without credentials

```bash
#!/bin/sh
# needs: RAILWAY_PUBLIC_DOMAIN, APTABASE_APP_KEY (variables of the aptabase service); also curl.
R="https://$RAILWAY_PUBLIC_DOMAIN"
n=0; until [ "$(curl -s -o /dev/null -w '%{http_code}' "$R/healthz")" = 200 ]; do n=$((n+1)); [ "$n" -le 240 ] || break; sleep 5; done
curl -s -o /dev/null -w "health: %{http_code}\n" "$R/healthz"
# write-auth: an event with the app key is accepted, the same event with no key is refused before it reaches the app
B="{\"timestamp\":\"$(date -u +%Y-%m-%dT%H:%M:%SZ)\",\"sessionId\":\"agent-$$\",\"eventName\":\"agent_check\",\"systemProps\":{\"locale\":\"en-US\",\"appVersion\":\"1.0.0\",\"sdkVersion\":\"curl@1\"}}"
curl -s -o /dev/null -w "write with key: %{http_code}\n" -H "App-Key: $APTABASE_APP_KEY" -H "Content-Type: application/json" -d "$B" "$R/api/v0/event"
curl -s -o /dev/null -w "write without key: %{http_code}\n" -H "Content-Type: application/json" -d "$B" "$R/api/v0/event"
# signup: registration is closed, so an anonymous account-creation POST is refused
curl -s -o /dev/null -w "public signup: %{http_code}\n" -H "Content-Type: application/json" -d '{"name":"Stranger","email":"stranger@example.org"}' "$R/api/_auth/register"
```

Expected output against a fresh deploy (measured on the Railway demo; the output is recorded in `template.md`):

```text
health: 200
write with key: 200
write without key: 401
public signup: 403
```

The refusals are the contract: an event without the key answers 401 (`write without key: 401`), and an anonymous account-creation POST answers 403 (`public signup: 403`).

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

- **Agent-ready** - no deployer fields, a contract block, and one script that proves the server is healthy, an event with the key is accepted, a keyless event is refused and sign-up is closed.
- **No open registration** - the stock `/api/_auth/register` route is closed and the owner exists before the first request.
- **Readable logs** - the sign-in link shows up in Railway's log viewer as plain text instead of an empty line.
- **Data survives redeploys** - users and apps in PostgreSQL on a volume, events in ClickHouse on a volume, session keys on a volume.
- **Pinned** - the upstream image is pinned by digest and the wrapper by tag and digest.

## Common Use Cases

- **Privacy-first app analytics** - count sessions and events from a mobile or desktop app without cookies, device identifiers or a third party.
- **Self-hosted alternative to hosted product analytics** - keep usage data on your own infrastructure.
- **Analytics for an agent-built product** - an agent creates the deploy, reads the ingestion key from its variables and wires an SDK or a plain HTTP call into the app.

## Dependencies for Aptabase Hosting

- The aptabase service, a PostgreSQL service and a ClickHouse service, each with its volume, created by the template.

### Deployment Dependencies

- [Aptabase repository](https://github.com/aptabase/aptabase)
- [Aptabase website](https://aptabase.com)
- [Wrapper image source](https://github.com/bon5co/aptabase-railway)


## Similar templates

- [Plausible WordPress](https://railway.com/deploy/deploy-plausible-for-wordpress-sites) — Cookie-free WordPress stats from your own Plausible
- [Typesense Multilingual](https://railway.com/deploy/deploy-typesense-multilingual-search) — Locale-aware multilingual search with Typesense
- [Formbricks](https://railway.com/deploy/formbricks-surveys) — Surveys, NPS and in-app feedback on your own Postgres, Hub and Cube

Open this page in a browser: https://railway.com/deploy/aptabase-or-just-updated-privacy-first-a
