Why self-host PostHog on a VPS
PostHog captures very detailed, sometimes sensitive product events. The vendor's cloud bills by event volume, which becomes costly for an active application. When self-hosted, you keep the behavioural data with you, you handle large volumes for a fixed server cost, and you enable every module (replay, flags, experiments) with no paid tier.
The concrete benefits of a self-hosted PostHog
- Product and session data kept on your infrastructure.
- High event volume with no usage-based billing.
- A complete suite: analytics, session replay, feature flags, A/B testing.
- Direct integration with your applications via the official SDKs.
- Predictable cost, sized by the VPS resources.
Hardware and software requirements
PostHog is the most demanding solution on this list: it ships with ClickHouse, Kafka, Redis and PostgreSQL. Count on at least 4 vCPU and 8 GB of RAM, and more in production. Plan for 30 GB of disk or more for the events. On the software side: Docker and Docker Compose, a domain name (e.g. posthog.your-domain.com) pointing to the VPS, and port 443 open.
Deploy PostHog self-hosted with Docker
Provision a properly sized VPS
Choose an instance of at least 4 vCPU / 8 GB of RAM. Over SSH, update the system and install Docker via curl -fsSL https://get.docker.com | sh.
Launch the official deployment
Follow PostHog's self-host installation script, which generates the full docker-compose (web, workers, ClickHouse, Kafka, Redis, PostgreSQL) and asks for your domain name.
Fill in the domain and the secrets
Set SITE_URL=https://posthog.your-domain.com and the generated secrets. Check that DNS points correctly to the VPS before continuing, so the certificate can be issued.
Start the stack
Run docker compose up -d and be patient: the first start initialises several services. Follow the logs until the web service responds.
Handle TLS
The official deployment includes Caddy for automatic HTTPS. If you use your own proxy, point posthog.your-domain.com to the exposed web port.
Create the project and wire up an SDK
Open the URL, create the administrator account and the first project, then integrate the SDK (JS, Python…) with the provided key to start capturing events.
PostHog is not designed for very small machines: under-sizing the VPS causes ClickHouse or Kafka crashes. Go big on RAM, and monitor the disk space that events consume quickly.
The official documentation
For advanced configuration and options specific to the tool, refer to the official PostHog documentation. This guide covers going live on a VPS; the vendor's documentation remains the reference for fine-tuning, major updates and specific use cases.