All tutorials

Running PostHog Product Analytics on Koyeb

4 min


PostHog is a developer-friendly open-source product analytics tool. With PostHog, you can automate the collection of events on your websites and apps and analyze them without sending data to third parties.

By deploying your PostHog application on Koyeb you benefit from native autoscaling, Automatic HTTPS (SSL) on all apps you deployed, high availability, and global load-balancing & CDN to make your applications global.


To successfully deploy PostHog on Koyeb, you need:


In order to deploy your PostHog app to Koyeb, you have to follow these steps:

  1. Create a new Koyeb App to deploy PostHog
  2. Deploy Redis
  3. Create Secrets for PostHog App and PostgreSQL Connection
  4. Deploy PostHog on Koyeb

Create a new Koyeb App to deploy PostHog

Start by creating a new Koyeb App we will deploy and run PostHog. In a terminal execute the following commands to create a new App:

koyeb app create posthog

Deploy Redis

With the PostHog Koyeb App created, we now can deploy the Redis service required by PostHog. In a terminal, execute the following command to deploy the Redis instance:

koyeb service create redis -a posthog --docker redis:6-alpine --ports 6379:tcp --routes ""

Create Secrets for PostHog App and PostgreSQL Database

Koyeb Secrets allow you to securely store and retrieve sensitive information like passwords. All Secret values are automatically encrypted server-side to ensure secure storage. To find out more about Koyeb Secrets, read our documentation about it here.

Koyeb Secret for PostHog Instance

For PostHog to work, you must create a SECRET_KEY that is unique to your PostHog instance. This SECRET_KEY is very important because it is used to encrypt cookies and password reset emails.

To create your SECRET_KEY and store it as a Koyeb Secret, in your terminal execute:

openssl rand -hex 32 | koyeb secret create posthog-secret-key --value-from-stdin

The command below generates a new key and creates a new Koyeb Secret posthog-secret to securely store the key on Koyeb.

Koyeb Secret for PostgreSQL Database Connection

Create a Koyeb secret to securely store your PostgreSQL connection URL.

In the terminal execute the following command and replace the following values with your own:

  • <DB_USERNAME>: PostgreSQL username
  • <DB_PASSWORD>: PostgreSQL password
  • <DB_HOST>: PostgreSQL host
  • <DB_PORT>: PostgreSQL port
  • <DB_NAME>: PostgreSQL database name
$koyeb secret create posthog-db-url
 Enter your secret: postgres://<DB_USERNAME>:<DB_PASSWORD>@<DB_HOST>:<DB_PORT>/<DB_NAME>

Deploy PostHog on Koyeb

With al the previous steps completed, you are ready to deploy PostHog on Koyeb. In the terminal execute the following command:

koyeb service create posthog -a posthog --docker posthog/posthog:latest --ports 8000:http --routes /:8000 --env REDIS_URL=redis://redis --env SECRET_KEY=@posthog-secret-key --env DATABASE_URL=@posthog-db-url --env IS_BEHIND_PROXY=1

Within a few minutes you will be able to access your PostHog instance at https://posthog-<YOUR_KOYEB_ORG_NAME>

You can track the deployment logs in your terminal with this command:

koyeb service logs posthog

Your PostHog application is now running on Koyeb and benefits from native autoscaling, automatic HTTPS (SSL), auto-healing, and global load-balancing across our edge network.


In this guide, we saw how easy it is to deploy PostHog on Koyeb and how to interact with the Koyeb platform using the CLI.

If you would like to read more Koyeb tutorials, checkout out our tutorials collection. Have an idea for a tutorial you'd like us to cover? Let us know by joining the conversation over on the Koyeb community platform!

Want to deploy your workloads on Koyeb? We let you run web apps, APIs, background workers, and more using git-based deployment or Docker containers! Enjoy native autoscaling, free SSL, a global edge network, and built-in service mesh and discovery with near zero configuration. Sign up and get started now


Welcome to Koyeb

Koyeb is a developer-friendly serverless platform to deploy any apps globally.

  • Start for free, pay as you grow
  • Deploy your first app in no time
Start for free
The fastest way to deploy applications globally.