Railway

Deploy PostHog Hobby

Deploy and Host PostHog Hobby with Railway

Deploy PostHog Hobby

/var/lib/postgresql/data

Just deployed

/data

/var/lib/clickhouse

Just deployed

Just deployed

Deploy and Host PostHog Hobby

PostHog Hobby is a reliable self-hosted deployment of PostHog — a complete product analytics platform with event tracking, feature flags, session recordings, funnels, and dashboards. This template ships a hobby-tier configuration pinned to a specific PostHog commit, with healthchecks on every service and a one-shot migration runner so upgrades stay clean.

About Hosting PostHog Hobby

This template runs the official PostHog application stack on Railway with 10 pre-configured services, each pinned to immutable image tags rather than latest. The setup mirrors PostHog's official docker-compose.hobby.yml but adapts it for Railway's per-service architecture: ZooKeeper is replaced with Redpanda (KRaft mode, single binary), ClickHouse ships pre-baked with PostHog's required cluster topology and UDFs, and migrations run as a separate one-shot service to avoid races on rebuild.

Pinned to PostHog sha-70c912d (2026-05-04). All cross-service connections use Railway's private network with auto-generated secrets. After the first deploy, redeploy the Web service once to pick up the CAPTURE_ENDPOINT reference (Railway's public domains populate after the first build).

Resources: requires approximately 8 GB RAM total. Railway Pro plan recommended (~$25-30/mo). Single-broker Kafka (Redpanda) is suitable for projects up to ~1M events/day.

Why Deploy PostHog Hobby?

PostHog Cloud charges per event, which scales painfully for high-traffic applications. This template gives you the full PostHog feature set at fixed Railway pricing — no per-event billing, no data sent to third parties, no row limits.

Unlike other PostHog Railway templates, this one:

  • Pins every image to a specific commit SHA instead of :latest — no surprise breakage when upstream pushes a regression
  • Uses upstream PostHog images (posthog/posthog, ghcr.io/posthog/posthog/capture, ghcr.io/posthog/posthog/plugin-server) — no fork dependency or bus factor risk
  • Includes healthchecks on Web, Plugins, Capture, and ClickHouse — Railway routes traffic only to ready instances
  • Runs migrations as a separate one-shot service — Web/Worker rebuild without re-running migrations, no blocking
  • Ships a custom ClickHouse image with PostHog's required cluster topology, user profile flags, UDFs (funnel aggregations), and Kafka IDL schemas pre-baked
  • Drops unnecessary services: no ZooKeeper (Redpanda KRaft replaces Kafka+ZK), no SeaweedFS (MinIO covers session recordings), no Temporal/livestream (advanced features moved to optional add-ons documented in README)

Common Use Cases

  • Product analytics for SaaS startups — track signups, conversions, feature adoption, retention without sending data to Mixpanel/Amplitude/PostHog Cloud
  • Feature flag rollouts — gradual feature releases, A/B tests, kill switches with sub-second flag evaluation in your private network
  • Session recordings for support/UX teams — replay user sessions to debug issues or understand behavior, stored in your own MinIO bucket
  • Funnel and retention analysis — built-in funnel UDFs (aggregate_funnel) for conversion analysis without extra setup
  • GDPR/data residency compliance — keep all event data inside your own Railway project, no external processors
  • Dogfood / internal tools — give your team a self-hosted PostHog instance for experiments without affecting production analytics

Dependencies for PostHog Hobby

PostHog Hobby bundles every dependency it needs as separate services in this template — you don't need to provision anything externally. The full stack:

  • Web (posthog/posthog) — Django app serving the UI and REST API
  • Worker (posthog/posthog) — Celery worker + scheduler for async tasks (reports, exports, cohort calculation)
  • Plugins (ghcr.io/posthog/posthog/plugin-server) — Node.js event ingestion pipeline, transformations, hooks
  • Capture (ghcr.io/posthog/posthog/capture) — Rust event capture service, public endpoint for SDKs
  • Migrate (posthog/posthog) — one-shot migration runner (Postgres + ClickHouse), exits after success
  • ClickHouse (ghcr.io/ikatsuba/posthog-clickhouse) — column store for events, with PostHog configs baked in
  • Postgres 15 (postgres:15.12-alpine) — application metadata, users, dashboards
  • Redis 7 (redis:7.2-alpine) — Celery broker and cache
  • Kafka / Redpanda (redpandadata/redpanda) — event bus between Capture and Plugins (KRaft mode, no ZooKeeper)
  • MinIO (minio/minio) — S3-compatible storage for session recordings and exports

Deployment Dependencies

  • Railway account with Pro plan or comparable resource budget — minimum ~8 GB RAM total across the stack, ClickHouse alone needs 2 GB+
  • Railway region close to your users (lower latency for Capture event ingestion)
  • Optional: custom domain for the Web service if you want PostHog at analytics.yourcompany.com instead of *.up.railway.app

After deploy, follow these one-time steps:

  1. Wait for Migrate to exit cleanly (Stopped status in Railway UI = success)
  2. Verify Web, Plugins, Capture, ClickHouse show Healthy
  3. Redeploy the Web service once to pick up the CAPTURE_ENDPOINT reference (circular dependency on first deploy)
  4. Open the Web public URL and complete the PostHog setup wizard

Template Content

More templates in this category

View Template
Foundry Virtual Tabletop
A Self-Hosted & Modern Roleplaying Platform

Lucas
View Template
Letta Code Remote
Run a Letta Code agent 24/7. No inbound ports, just deploy.

Letta
View Template
(v1) Simple Medusa Backend
Deploy an ecommerce backend and admin using Medusa

Shahed Nasser