Skip to content

Self-hosting

One command on any machine with Docker. Postgres, ClickHouse, the app and the ingest server, with secrets generated for you.

Let your coding agent do it

Paste this prompt into Claude Code, Codex or Cursor in an empty folder. It checks Docker, runs the installer and tells you where to log in. It asks before installing anything.

Preview prompt
Set up hostpog (open-source product analytics) on this machine.

Repository: https://github.com/dhanush17-tech/hostpog

Do this step by step and tell me what you did after each step:
1. Check that Docker is installed and running (docker info) and that Docker Compose v2 works (docker compose version). If not, tell me how to install or start Docker for my OS and wait — don't install system software yourself.
2. Clone the repository (skip if I'm already inside it) and cd into it.
3. Run ./hostpog up. The first run generates secrets into deploy/.env and builds the images (a few minutes). Never print the secrets back to me and never commit deploy/.env.
4. If port 3000 or 3001 is taken, change WEB_PORT/INGEST_PORT and the matching HOSTPOG_PUBLIC_URL / HOSTPOG_INGEST_PUBLIC_URL in deploy/.env, then run ./hostpog up again. For any other failure, show me ./hostpog logs and your proposed fix before changing code.
5. Finish by telling me: the URL to open, that I should create an account there, and that I'll connect PostHog or add an AI key from inside the app (I'll paste keys there myself — don't ask me for them here). Remind me to back up deploy/.env.

Get your keys

You only need the ones you'll use. Each button opens the exact page where the key is created; you paste it into hostpog afterwards.

PostHog (to connect existing data)

PostHog US Cloud

Create a personal API key with read access (query:read is the one that matters).

Open US key page

PostHog EU Cloud

Same as above, for projects hosted in the EU.

Open EU key page

Not sure which? Look at the address bar when you're logged into PostHog — it starts with us. or eu.. Self-hosted PostHog: open /settings/user-api-keys on your own domain.

AI model (for investigations — optional)

Google Gemini

Fastest way to start: AI Studio has a free tier and no billing setup.

Get a Gemini key

OpenRouter

One key for hundreds of models from every major lab.

Get an OpenRouter key

Anthropic (Claude)

Create a key in the Claude Console. Requires billing on the account.

Get a Claude key

OpenAI

Create a project API key. Requires billing on the account.

Get an OpenAI key

Local model (Ollama)

Keeps everything on your machine. Set HOSTPOG_AI_ALLOWED_PRIVATE_HOSTS=localhost.

Download Ollama

Quickstart

git clone https://github.com/dhanush17-tech/hostpog hostpog && cd hostpog
./hostpog up

Open http://localhost:3000 and create an account. The first run builds the images (a few minutes) and writes generated secrets to deploy/.env. Back that file up: HOSTPOG_MASTER_KEY encrypts every stored PostHog and AI key.

./hostpog upStart everything (first run: generate secrets and build).
./hostpog status / logsService health, or follow logs (./hostpog logs web).
./hostpog updateRebuild from your checkout after git pull and restart. Migrations run automatically.
./hostpog backupPostgres dump to ./backups.
./hostpog downStop. Data stays in Docker volumes.

Requirements

  • Docker with Compose v2 (Docker Desktop on Mac/Windows)
  • 2 GB RAM minimum, 4 GB+ recommended (ClickHouse likes memory)
  • On a server: put a TLS proxy (Caddy, nginx) in front of ports 3000 and 3001 and set the https URLs in deploy/.env before the first run

One ingest instance handles roughly 2,000–5,000 events per second (see docs/loadtest.md).

Developing on hostpog

cp .env.example .env
echo "HOSTPOG_MASTER_KEY=$(openssl rand -base64 32)" >> .env
echo "BETTER_AUTH_SECRET=$(openssl rand -base64 32)" >> .env
pnpm install
pnpm infra:up       # postgres, clickhouse, redis (dev credentials only)
pnpm db:migrate
pnpm dev            # web on :3000, ingest on :3001

Configuration

HOSTPOG_MASTER_KEY32-byte base64 key encrypting stored credentials (AES-256-GCM). Required.
BETTER_AUTH_SECRETSession signing secret. Required.
HOSTPOG_PUBLIC_URLBrowser URL. Used for CSRF origin checks, cookies (Secure when https) and OAuth.
HOSTPOG_POSTHOG_ALLOWED_HOSTSSelf-hosted PostHog origins users may connect to. Anything else is refused (SSRF protection).
HOSTPOG_AI_ALLOWED_PRIVATE_HOSTSPrivate/local model hosts (e.g. localhost for Ollama). Private addresses are blocked otherwise.
HOSTPOG_POSTHOG_OAUTH_ENABLEDEnable PostHog OAuth. Requires a public HTTPS HOSTPOG_PUBLIC_URL because PostHog fetches HostPog's client metadata document at /oauth/posthog-client.json.

Rotating the master key

  1. Move the current key to HOSTPOG_MASTER_KEY_PREVIOUS (and its version to _PREVIOUS_VERSION).
  2. Set a new HOSTPOG_MASTER_KEY with a higher HOSTPOG_MASTER_KEY_VERSION. Old ciphertexts still decrypt; new writes use the new key.
  3. Rotate credentials (Integrations → Rotate key, AI providers → re-add) to re-encrypt, then remove the previous key.

Backups

# Postgres (accounts, sources, encrypted credentials, dashboards, investigations)
./hostpog backup
# ClickHouse (native events) — use BACKUP ... TO Disk/S3, see ClickHouse docs

Back up the master key separately from the database. Without it, stored credentials cannot be decrypted.

Production notes

  • Terminate TLS in front of web and ingest; set HOSTPOG_PUBLIC_URL to the https URL.
  • Investigations run inside the web process, so use a long-running server rather than a serverless host.
  • hostpog sends no telemetry about your instance.