Deploy PostHog on Dokku

This guide can also be found directly in the dokku-posthog repository.

Run PostHog on Dokku

What is PostHog?

PostHog is an open-source product analytics suite, built for developers. Automate the collection of every event on your website or app, with no need to send data to 3rd parties.

What is Dokku?

Dokku is the smallest PaaS implementation you've ever seen - Docker powered mini-Heroku.


  • A working Dokku host
  • PostgreSQL plugin for Dokku
  • Redis plugin for Dokku
  • Letsencrypt plugin for SSL (optionnal)
  • Setup

    Note: We are going to use the domain for demonstration purposes. Make sure to replace it with your own domain name.

    App and plugins

    Create the app

    Log onto your Dokku Host to create the PostHog app:

    dokku apps:create posthog

    Add plugins

    Install, create and link PostgreSQL plugin:

    # Install plugins dokku plugin:install postgres dokku plugin:install redis

    # Create running plugins dokku postgres:create posthog dokku redis:create posthog

    # Link plugins to the main app dokku postgres:link posthog posthog dokku redis:link posthog posthog

    Configure dokku app

    Environment variables

    dokku config:set posthog POSTGRES_DB=posthog POSTGRES_PASSWORD=<...> POSTGRES_USER=postgres SECRET_KEY=<...>


    Extract password from existing

    # Show all enironement variables to copy content of DATABASE_URL variable dokku config posthog

    Copy the password from DATABASE_URL

    dokku config:set posthog POSTGRES_DB=posthog POSTGRES_PASSWORD=<found in DATABSE_URL>

    Web app

    dokku config:set posthog SECRET_KEY=<randomly generated secret key> SITE_URL= IS_BEHIND_PROXY=True DISABLE_SECURE_SSL_REDIRECT=True

    Set up the domain

    To get the routing working, we need to apply a few settings. First we set the domain.

    dokku domains:set posthog

    Then we set the ports to redirect to

    dokku proxy:ports-set posthog http:80:8000 https:443:8000

    Push PostHog to Dokku

  • Clone the dokku-posthog repository.
  • Set up your Dokku server as a remote.
  • git remote add dokku

  • Push it to Dokku
  • git push dokku master

    Add SSL certificate (to enable HTTPS)

    Last but not least, we can go an grab the SSL certificate from Let's Encrypt.

    # Install letsencrypt plugin dokku plugin:install # Set certificate contact email dokku config:set --no-restart posthog # Generate certificate dokku letsencrypt posthog

    Wrapping up

    Your PostHog instance should now be available on