Self-Hosting Plausible Analytics With Dokku

📖 4 min read

In my search for a self-hosted alternative to Google Analytics, I found Plausible Analytics. Plausible is an open-source and privacy focused alternative to Google Analytics, which I wanted to remove entirely from my sites. Self-hosting with the instructions from their documentation is not geared towards someone trying to host it on a Dokku host. This guide will help walk you through the steps of setting up Plausible on a Dokku host. We will create the application, install the required plugins, create all the necessary databases, link them to the application, and deploy the application.

What is Dokku?

Dokku is a popular, open-source, and self-hosted platform as a service (PaaS) that allows users to easily deploy and manage their applications, very similar to your own self-hosted Heroku. Under the hood, Dokku is powered by Docker, uses Heroku buildpacks by default, and has a number of official and community plugins.

There is a one-click install image you can use from Digital Ocean, but I personally like to start with a fresh box and enjoy installing and configuring it all myself.

The only system requirements are 1GB of memory and either Ubuntu 18.04/20.04 x64, Debian 9+ x64, or CentOS 7 x64.

You can read more about using Dokku in my blog post yesterday.

What is Plausible?

Plausible is an open-source and privacy focused alternative to Google Analytics. It uses no cookies and is fully compliant with GDPR, CCPA, and PECR. While it is easiest to just pay the $6 / per month for a cloud hosted instance, I will always choose self-hosted if it is an option and here is no exception. Self-hosting with the instructions from their documentation is not geared towards someone trying to host it on Dokku. Because of it, I wanted to document the process in hopes of helping others set up their own instance of Plausible.

The only requirement is a working Dokku host.

We are going to use the domain for demonstration purposes. Be sure to replace it with your own domain name when running through the bash command snippets.

First, we're going to SSH into your Dokku Host and create the Plausible app:

dokku apps:create plausible

Next, we will install the PostgreSQL and Clickhouse plugins, if they aren't already installed.

dokku plugin:install postgres
dokku plugin:install clickhouse

And then, we'll create our instances of the PostgresSQL and Clickhouse databases.

dokku postgres:create plausible-db
dokku clickhouse:create plausible-events-db

Let's then set the environment variables for the database scheme, which just sets it to use the scheme expected within the Plausible Docker image. Then we'll link the databases to the application.

dokku config:set plausible CLICKHOUSE_DATABASE_SCHEME=http
dokku postgres:link plausible-db plausible
dokku clickhouse:link plausible-events-db plausible

Next, we'll slightly adjust the URL that was provided from linking the Clickhouse database and change the name of the environment variable for it as well to match what is expected within the Plausible docker image.

dokku config:set plausible CLICKHOUSE_DATABASE_URL=$(dokku config:get plausible CLICKHOUSE_URL)/plausible
dokku config:unset plausible CLICKHOUSE_URL

Then, we'll generate a secrete key using openssl.

dokku config:set plausible SECRET_KEY_BASE=$(openssl rand -base64 64 | tr -d '\n')

And then, we'll set the BASE_URL environment variable and set the domain for the application — make sure to use your domain here.

dokku config:set plausible BASE_URL=
dokku domains:set plausible

Set the required SMTP environment variables to set up transactional emails.

dokku config:set plausible \ \
SMTP_USER_PWD=example1234 \

Let's set up our admin account for the application. And then, we can optionally disable registration, this is especially useful if this is just for you and you aren't inviting any clients or other users to utilize it.

dokku config:set plausible \
## This is optional!
dokku config:set plausible DISABLE_REGISTRATION=true

Next, we need to clone (or fork!) the my repository on your local machine.

## Via SSH
git clone
git clone

Set the Dokku host as the git remote for the repository and push it on up to your Dokku host!

git remote add dokku
git push dokku master

After the initial push and deploy, we can then finally set up the SSL certificate from Let's Encrypt.

Let's start by installing the Let's Encrypt plugin, if you don't already have it installed.

dokku plugin:install letsencrypt

Then we can set the certificate contact email.

dokku config:set --no-restart plausible

And finally, generate the certificates!

dokku letsencrypt plausible

At this point your instance of Plausible should be accessible via, the domain your provided, which for us is

Profit!!! 🎉🎉🎉