
Deploy PostHog on Your Own Server
π¦ PostHog provides open-source product analytics, session recording, feature flagging and A/B testing that you can self-host.
Want to deploy PostHog on your server faster? Try Senate with one-command setup, automatic HTTPS and monitoring.
What is PostHog?
Enter your PostHog Configuration parameters and click on next. The process will take a just a few minutes to finish. **Note**: This One Click App deploys a **total of 16 different apps** and it requires at least 8GB of RAM with a a Quad-Core CPU.
Self-Host PostHog
Follow these steps to deploy on your own server.
Install Docker
Skip this step if Docker is already installed on your server.
curl -fsSL https://get.docker.com | sh
Configure
Customize the settings below. Defaults work for most cases.
General
Deploy
Copy the configuration and run it on your server.
services:
posthog-clickhouse:
volumes:
- clickhouse-data:/var/lib/clickhouse
posthog-db:
image: postgres:12-alpine
environment:
POSTGRES_DB: posthog
POSTGRES_PASSWORD: da7bf12ac641
POSTGRES_USER: posthog
volumes:
- posthog-postgres-data:/var/lib/postgresql/data
posthog-elasticsearch:
image: elasticsearch:7.16.2
environment:
ES_JAVA_OPTS: -Xms256m -Xmx256m
cluster.routing.allocation.disk.threshold_enabled: "true"
cluster.routing.allocation.disk.watermark.flood_stage: 128mb
cluster.routing.allocation.disk.watermark.high: 256mb
cluster.routing.allocation.disk.watermark.low: 512mb
discovery.type: single-node
xpack.security.enabled: "false"
volumes:
- posthog-elasticsearch:/var/lib/elasticsearch/data
posthog-kafka:
image: ghcr.io/posthog/kafka-container:v2.8.2
environment:
ALLOW_PLAINTEXT_LISTENER: "true"
KAFKA_BROKER_ID: "1001"
KAFKA_CFG_ADVERTISED_LISTENERS: PLAINTEXT://posthog-kafka:9092
KAFKA_CFG_LISTENERS: PLAINTEXT://:9092
KAFKA_CFG_RESERVED_BROKER_MAX_ID: "1001"
KAFKA_CFG_ZOOKEEPER_CONNECT: posthog-zookeeper:2181
volumes:
- posthog-kafka-data:/bitnami/kafka
depends_on:
- posthog-zookeeper
posthog-objectstorage:
image: minio/minio:RELEASE.2022-06-25T15-50-16Z
environment:
MINIO_ROOT_PASSWORD: 1dd8add49cf7b71b5c1ceb2
MINIO_ROOT_USER: object_storage_root_user
volumes:
- posthog-objectstorage:/data
ports:
- 19000:19000
- 19001:19001
posthog-plugin:
image: posthog/posthog:e2f4b4a8b46667f75ad9bdacf4a487a5dd2d5dbf
environment:
CDP_REDIS_HOST: posthog-redis7
CDP_REDIS_PORT: "6379"
CLICKHOUSE_HOST: posthog-clickhouse
CLICKHOUSE_SECURE: "false"
DATABASE_URL: postgres://posthog:da7bf12ac641@posthog-db:5432/posthog
DISABLE_SECURE_SSL_REDIRECT: "true"
KAFKA_HOSTS: posthog-kafka:9092
OBJECT_STORAGE_ACCESS_KEY_ID: object_storage_root_user
OBJECT_STORAGE_ENABLED: "true"
OBJECT_STORAGE_ENDPOINT: http://posthog-objectstorage:19000
OBJECT_STORAGE_SECRET_ACCESS_KEY: 1dd8add49cf7b71b5c1ceb2
REDIS_URL: redis://posthog-redis:6379/
SECRET_KEY: 77633b76fd8ab99b30dc4dd
SITE_URL: http://posthog-web.your-domain.com
depends_on:
- posthog-db
- posthog-redis
- posthog-clickhouse
- posthog-kafka
- posthog-objectstorage
posthog-redis:
image: redis:6.2.7-alpine
posthog-redis7:
image: redis:7.2-alpine
posthog-temporal:
image: temporalio/auto-setup:1.20.0
environment:
DB: postgresql
DB_PORT: "5432"
ENABLE_ES: "false"
ES_SEEDS: posthog-elasticsearch
ES_VERSION: v7
POSTGRES_PWD: da7bf12ac641
POSTGRES_SEEDS: posthog-db
POSTGRES_USER: posthog
ports:
- 7233:7233
depends_on:
- posthog-elasticsearch
- posthog-db
posthog-temporal-admin-tools:
image: temporalio/admin-tools:1.20.0
environment:
TEMPORAL_CLI_ADDRESS: posthog-temporal:7233
depends_on:
- posthog-temporal
posthog-temporal-django-worker:
image: posthog/posthog:e2f4b4a8b46667f75ad9bdacf4a487a5dd2d5dbf
environment:
CLICKHOUSE_HOST: posthog-clickhouse
CLICKHOUSE_SECURE: "false"
DATABASE_URL: postgres://posthog:da7bf12ac641@posthog-db:5432/posthog
DISABLE_SECURE_SSL_REDIRECT: "true"
IS_BEHIND_PROXY: "true"
KAFKA_HOSTS: posthog-kafka:9092
REDIS_URL: redis://posthog-redis:6379/
SECRET_KEY: 77633b76fd8ab99b30dc4dd
SITE_URL: http://posthog-web.your-domain.com
TEMPORAL_HOST: posthog-temporal
TRUST_ALL_PROXIES: "false"
depends_on:
- posthog-db
- posthog-redis
- posthog-clickhouse
- posthog-kafka
- posthog-objectstorage
- posthog-temporal
posthog-temporal-ui:
image: temporalio/ui:2.10.3
environment:
TEMPORAL_ADDRESS: posthog-temporal:7233
TEMPORAL_CORS_ORIGINS: http://localhost:3000
ports:
- 8081:8080
depends_on:
- posthog-temporal
- posthog-db
posthog-web:
image: posthog/posthog:e2f4b4a8b46667f75ad9bdacf4a487a5dd2d5dbf
environment:
CLICKHOUSE_HOST: posthog-clickhouse
CLICKHOUSE_SECURE: "false"
DATABASE_URL: postgres://posthog:da7bf12ac641@posthog-db:5432/posthog
DISABLE_SECURE_SSL_REDIRECT: "true"
IS_BEHIND_PROXY: "true"
KAFKA_HOSTS: posthog-kafka:9092
OBJECT_STORAGE_ACCESS_KEY_ID: object_storage_root_user
OBJECT_STORAGE_ENABLED: "true"
OBJECT_STORAGE_ENDPOINT: http://posthog-objectstorage:19000
OBJECT_STORAGE_SECRET_ACCESS_KEY: 1dd8add49cf7b71b5c1ceb2
REDIS_URL: redis://posthog-redis:6379/
SECRET_KEY: 77633b76fd8ab99b30dc4dd
SITE_URL: http://posthog-web.your-domain.com
TRUST_ALL_PROXIES: "false"
depends_on:
- posthog-db
- posthog-redis
- posthog-clickhouse
- posthog-kafka
posthog-worker:
image: posthog/posthog:e2f4b4a8b46667f75ad9bdacf4a487a5dd2d5dbf
environment:
CLICKHOUSE_HOST: posthog-clickhouse
CLICKHOUSE_SECURE: "false"
DATABASE_URL: postgres://posthog:da7bf12ac641@posthog-db:5432/posthog
DISABLE_SECURE_SSL_REDIRECT: "true"
IS_BEHIND_PROXY: "true"
KAFKA_HOSTS: posthog-kafka:9092
OBJECT_STORAGE_ACCESS_KEY_ID: object_storage_root_user
OBJECT_STORAGE_ENABLED: "true"
OBJECT_STORAGE_ENDPOINT: http://posthog-objectstorage:19000
OBJECT_STORAGE_SECRET_ACCESS_KEY: 1dd8add49cf7b71b5c1ceb2
REDIS_URL: redis://posthog-redis:6379/
SECRET_KEY: 77633b76fd8ab99b30dc4dd
SITE_URL: http://posthog-web.your-domain.com
TRUST_ALL_PROXIES: "false"
posthog-zookeeper:
image: zookeeper:3.7.0
volumes:
- posthog-zookeeper-datalog:/datalog
- posthog-zookeeper-data:/data
- posthog-zookeeper-logs:/logs
volumes:
clickhouse-data: {}
posthog-postgres-data: {}
posthog-elasticsearch: {}
posthog-kafka-data: {}
posthog-objectstorage: {}
posthog-zookeeper-datalog: {}
posthog-zookeeper-data: {}
posthog-zookeeper-logs: {}
Then run:
docker compose up -d
Access
Once started, access your app at http://localhost:80
Why Self-Host PostHog?
Full Data Ownership
Your data stays on your servers. No third-party access.
No Monthly Fees
Pay only for your server. No per-seat or usage charges.
Complete Control
Customize, backup, and scale on your own terms.
Privacy & Compliance
Meet GDPR, HIPAA, or internal security requirements.
Technical Details
Want to go faster?
Try Senate! Senate handles Docker, HTTPS, updates, and monitoring for you. Deploy any of our 300+ apps with a single command.
Install on any Linux server:
sh -c "$(curl -sSL https://get.senate.sh)"