Deployment guide

How to Host PostHog on a VPS

Deploy on a VPS Cloud →

Self-hosting8 min read

How to Host PostHog on a VPS

PostHog is an all-in-one product analytics platform: event tracking, funnels, session replay, feature flags and A/B testing in a single tool. Self-hosted on your VPS, it keeps your users' behaviour on your infrastructure, with no billing by event volume. Here is how to deploy it with Docker and the official self-host configuration.

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

01

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.

02

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.

03

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.

04

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.

05

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.

06

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.

Deploy your instance on a ServOrbit Cloud VPS

A ServOrbit Cloud VPS with Docker preconfigured and scalable resources lets you install this tool without friction, and adjust RAM and vCPU as usage grows.

Need help?

Browse our help center and FAQ, or write to our team — support in French, English and Arabic.