Skip to main content
This guide walks you through setting up PostHog for local development. You’ll be able to run the full stack including Django, React, PostgreSQL, ClickHouse, and Redis.

Prerequisites

1

System Requirements

  • macOS or Linux (Windows via WSL2)
  • 16GB RAM minimum (32GB recommended)
  • 20GB free disk space
  • Docker Desktop (for infrastructure services)
2

Required Tools

Install these tools before proceeding:
  • Git - Version control
  • Docker - For PostgreSQL, ClickHouse, Redis
  • Node.js 18+ - Frontend tooling
  • Python 3.11+ - Backend runtime
  • pnpm - Package manager

Quick Start

The fastest way to get started is using the automated setup:
The ./bin/start script uses mprocs to run all services in parallel. It will automatically install mprocs via Homebrew if not present.
PostHog will be available at:

Detailed Setup

1. Environment Setup

Flox provides a reproducible development environment:
This automatically installs:
  • Python 3.11 with required packages
  • Node.js and pnpm
  • PostgreSQL and ClickHouse clients
  • All development tools

Option B: Manual Setup

If not using Flox, install dependencies manually:

2. Infrastructure Services

Start PostgreSQL, ClickHouse, and Redis using Docker:
Services started:
  • PostgreSQL on localhost:5432
  • ClickHouse on localhost:9000 (HTTP: 8123)
  • Redis on localhost:6379
  • Kafka on localhost:9092 (for event ingestion)
  • Object Storage (MinIO) on localhost:19000
If ports are already in use, you can modify them in docker-compose.dev.yml.

3. Database Setup

Initialize both PostgreSQL and ClickHouse:
1

Create PostgreSQL database

2

Initialize ClickHouse

3

Load test data (optional)

4. Environment Variables

Create a .env file for local configuration:
Key environment variables:

5. Frontend Setup

Install and build frontend assets:

Running PostHog

The bin/start script runs all services in parallel:
This starts:
  • Django web server (port 8000)
  • Celery workers (background tasks)
  • Celery beat (scheduled tasks)
  • Frontend dev server (hot reload)
  • Plugin server (event processing)
  • Temporal worker (workflows)
Additional options:
Use Ctrl+A then K to navigate between services in mprocs. Press Q to quit all services.

Running Services Individually

For debugging or targeted development:

Development Workflow

Auto-Detection of Flox Environment

If using Flox, commands are automatically wrapped:
Never use flox activate in interactive sessions - it hangs. The auto-detection handles this for you.

Code Formatting

Hot Reloading

  • Frontend: Changes auto-reload at http://localhost:8000
  • Backend: Django auto-reloads on Python file changes
  • Styles: Tailwind CSS rebuilds automatically

Common Tasks

Create a New Product

Generate API Types

When you change Django serializers, regenerate TypeScript types:
This updates:
  • frontend/src/generated/core/api.ts
  • products/*/frontend/generated/api.ts

Create Database Migrations

Reset Database

Troubleshooting

If you see Address already in use errors:
Ensure Docker services are running:
Clear caches and reinstall:
If using Flox:
Without Flox:

Next Steps

Testing

Learn how to run and write tests

Contributing

Contribute code to PostHog