Upgrading Plausible from older beta to the most recent version

Currently I’m running a self-hosted instance of Plausible based on an older documentation of the beta version. It is really good to know that Plausible is now out of beta and the self hosting installation process is more docker friendly as we no longer require the setup step as was required for the earlier versions. Thanks a lot for providing a new image of Plausible on Docker Hub!

My query is, since our earlier installation is based on the beta, what are the necessary steps to transition to the new docker friendly method while upgrading Plausible? Should replacing the old Dockerfile with the new one in the GitHub repository suffice or should I make the Plausible service use the new image from now on?

I’m concerned about messing up the environment variables or any other configuration if I upgrade it based on the new installation steps as reference. I’m also running a corresponding geoip container.

Any help or advise regarding this matter would be highly appreciated. Thank you in advance.

Obviously the best thing to do if you’re unsure is to take backups before doing any upgrades!

Besides that, it’s pretty simple. There’s a few changes needed to get running on 1.0 which are in the changelog (https://github.com/plausible/analytics/releases/tag/v1.0.0), but they’re not massive, and of course you’ll need to run migrations before plausible will start, as I believe there have been a few schema changes.

1 Like

Thanks a lot @theorangeone ! I do have the backups already but was still concerned about the changes so wanted to make sure while making the upgrade. Thanks again!

I’ve been trying doing the upgrade based on the solution provided here but unfortunately was unable to. I also tried a fresh instance of Plausible based on the new self hosting documentation but the Plausible container keeps restarting itself after deployment. Earlier it worked fine with the older HOSTING.md doc with Jwilder’s Nginx config.

Now when I try to revert back to the previous setup based on an older fork of Plausible by following HOSTING.md, I still keep getting a “502 bad gateway” error(even for a fresh instance). Requesting the devs to please create a separate documentation for both doing an upgrade as well as for Jwilder’s Nginx.

@avimanyu could you try a fresh install following those repositories :


Also could you provide us a docker log of your plausible container ?

Thanks a lot for your reply @Holory.fr. I need to run it under Jwilder Nginx containers as I already have other instances running on it. I am able to run it on a separate test server by exposing port 8000 through a dockerfile. Now I’m attempting a fresh instance(removed old plausible related volumes) based on the latest version:

Dockerfile.custom:

from plausible/analytics:latest
expose 8000
workdir /app
entrypoint ["/entrypoint.sh"]
cmd ["run"] 

Here are my docker compose.yml files:

Plausible:

version: "3.3"
services:
  mail:
    image: bytemark/smtp
    restart: always
    networks:
      - common-network

  plausible_db:
    image: postgres:12
    volumes:
      - db-data:/var/lib/postgresql/data
    environment:
      - POSTGRES_PASSWORD=postgres
    restart: always
    networks:
      - common-network

  plausible_events_db:
    image: yandex/clickhouse-server:latest
    volumes:
      - event-data:/var/lib/clickhouse
    ulimits:
      nofile:
        soft: 262144
        hard: 262144
    restart: always
    networks:
      - common-network

  plausible:
    #build:
      #dockerfile: "./Dockerfile.custom"
      #context: '.'
    image: plausible/analytics:latest
    command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh db init-admin && /entrypoint.sh run"
    depends_on:
      - plausible_db
      - plausible_events_db
      - mail
    env_file:
      - plausible-conf.env
    restart: always
    networks:
      - common-network

volumes:
  db-data:
    driver: local
  event-data:
    driver: local
  geoip:
    driver: local

networks:
  common-network:
    external: true

Nginx:

version: '3.7'

services:

  nginx-proxy:
    image: jwilder/nginx-proxy
    container_name: nginx-proxy
    ports:
      - "80:80"
      - "443:443"
    volumes:
      - ./html:/usr/share/nginx/html
      - ./dhparam:/etc/nginx/dhparam
      - ./vhost:/etc/nginx/vhost.d
      - ./certs:/etc/nginx/certs:ro
      - /var/run/docker.sock:/tmp/docker.sock:ro
      - ./client_max_upload_size.conf:/etc/nginx/conf.d/client_max_upload_size.conf
    labels:
      - "com.github.jrcs.letsencrypt_nginx_proxy_companion.nginx_proxy"
    restart: always
    networks:
      - common-network

  letsencrypt:
    image: jrcs/letsencrypt-nginx-proxy-companion
    container_name: letsencrypt-proxy-companion
    env_file:
      - ./letsencrypt.env
    depends_on:
      - nginx-proxy
    volumes:
      - ./certs:/etc/nginx/certs:rw
      - ./vhost:/etc/nginx/vhost.d
      - ./html:/usr/share/nginx/html
      - /var/run/docker.sock:/var/run/docker.sock:ro
    restart: always
    networks:
      - common-network

networks:
  common-network:
    external: true

The docker logs show the following errors for the plausible container:

Loading plausible..
Starting dependencies..
Starting repos..
create Plausible.Repo database if it doesn't exist
create Plausible.ClickhouseRepo database if it doesn't exist
16:15:01.025 [error] GenServer #PID<0.265.0> terminating
** (RuntimeError) Code: 81, e.displayText() = DB::Exception: Database `` doesn't exist (version 20.6.4.44 (official build))

    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
16:15:01.025 [error] Clickhousex.Protocol (#PID<0.244.0>) failed to connect: ** (ErlangError) Erlang error: "Code: 81, e.displayText() = DB::Exception: Database plausible_events_db doesn't exist (version 20.6.4.44 (official build))\n"
16:15:01.025 [error] Clickhousex.Protocol (#PID<0.245.0>) failed to connect: ** (ErlangError) Erlang error: "Code: 81, e.displayText() = DB::Exception: Database plausible_events_db doesn't exist (version 20.6.4.44 (official build))\n"
16:15:01.032 [error] GenServer #PID<0.266.0> terminating
** (RuntimeError) Code: 81, e.displayText() = DB::Exception: Database `` doesn't exist (version 20.6.4.44 (official build))

    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
16:15:01.035 [error] GenServer #PID<0.267.0> terminating
** (RuntimeError) Code: 81, e.displayText() = DB::Exception: Database `` doesn't exist (version 20.6.4.44 (official build))

    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
16:15:01.038 [error] GenServer #PID<0.268.0> terminating
** (RuntimeError) Code: 81, e.displayText() = DB::Exception: Database `` doesn't exist (version 20.6.4.44 (official build))

    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
** (MatchError) no match of right hand side value: {:error, "killed"}
    (plausible 0.0.1) lib/plausible_release.ex:56: anonymous fn/2 in Plausible.Release.createdb/0
    (elixir 1.10.3) lib/enum.ex:2111: Enum."-reduce/3-lists^foldl/2-0-"/3
    (plausible 0.0.1) lib/plausible_release.ex:55: Plausible.Release.createdb/0
    (stdlib 3.12.1) erl_eval.erl:680: :erl_eval.do_apply/6
    (elixir 1.10.3) lib/code.ex:341: Code.eval_string_with_error_handling/3
Loading plausible..
Starting dependencies..
Starting repos..
create Plausible.Repo database if it doesn't exist
create Plausible.ClickhouseRepo database if it doesn't exist
16:15:14.409 [error] GenServer #PID<0.265.0> terminating
** (RuntimeError) Code: 81, e.displayText() = DB::Exception: Database `` doesn't exist (version 20.6.4.44 (official build))

    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
16:15:14.409 [error] Clickhousex.Protocol (#PID<0.244.0>) failed to connect: ** (ErlangError) Erlang error: "Code: 81, e.displayText() = DB::Exception: Database plausible_events_db doesn't exist (version 20.6.4.44 (official build))\n"
16:15:14.409 [error] Clickhousex.Protocol (#PID<0.245.0>) failed to connect: ** (ErlangError) Erlang error: "Code: 81, e.displayText() = DB::Exception: Database plausible_events_db doesn't exist (version 20.6.4.44 (official build))\n"
16:15:14.415 [error] GenServer #PID<0.266.0> terminating
** (RuntimeError) Code: 81, e.displayText() = DB::Exception: Database `` doesn't exist (version 20.6.4.44 (official build))

    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
16:15:14.418 [error] GenServer #PID<0.267.0> terminating
** (RuntimeError) Code: 81, e.displayText() = DB::Exception: Database `` doesn't exist (version 20.6.4.44 (official build))

    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
16:15:14.421 [error] GenServer #PID<0.268.0> terminating
** (RuntimeError) Code: 81, e.displayText() = DB::Exception: Database `` doesn't exist (version 20.6.4.44 (official build))

    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
** (MatchError) no match of right hand side value: {:error, "killed"}
    (plausible 0.0.1) lib/plausible_release.ex:56: anonymous fn/2 in Plausible.Release.createdb/0
    (elixir 1.10.3) lib/enum.ex:2111: Enum."-reduce/3-lists^foldl/2-0-"/3
    (plausible 0.0.1) lib/plausible_release.ex:55: Plausible.Release.createdb/0
    (stdlib 3.12.1) erl_eval.erl:680: :erl_eval.do_apply/6
    (elixir 1.10.3) lib/code.ex:341: Code.eval_string_with_error_handling/3
Loading plausible..
Starting dependencies..
Starting repos..
create Plausible.Repo database if it doesn't exist
create Plausible.ClickhouseRepo database if it doesn't exist
16:15:27.513 [error] Clickhousex.Protocol (#PID<0.244.0>) failed to connect: ** (ErlangError) Erlang error: "Code: 81, e.displayText() = DB::Exception: Database plausible_events_db doesn't exist (version 20.6.4.44 (official build))\n"
16:15:27.513 [error] Clickhousex.Protocol (#PID<0.245.0>) failed to connect: ** (ErlangError) Erlang error: "Code: 81, e.displayText() = DB::Exception: Database plausible_events_db doesn't exist (version 20.6.4.44 (official build))\n"
16:15:27.513 [error] GenServer #PID<0.265.0> terminating
** (RuntimeError) Code: 81, e.displayText() = DB::Exception: Database `` doesn't exist (version 20.6.4.44 (official build))

    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
16:15:27.519 [error] GenServer #PID<0.266.0> terminating
** (RuntimeError) Code: 81, e.displayText() = DB::Exception: Database `` doesn't exist (version 20.6.4.44 (official build))

    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
16:15:27.523 [error] GenServer #PID<0.267.0> terminating
** (RuntimeError) Code: 81, e.displayText() = DB::Exception: Database `` doesn't exist (version 20.6.4.44 (official build))

    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
16:15:27.526 [error] GenServer #PID<0.268.0> terminating
** (RuntimeError) Code: 81, e.displayText() = DB::Exception: Database `` doesn't exist (version 20.6.4.44 (official build))

    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
** (MatchError) no match of right hand side value: {:error, "killed"}
    (plausible 0.0.1) lib/plausible_release.ex:56: anonymous fn/2 in Plausible.Release.createdb/0
    (elixir 1.10.3) lib/enum.ex:2111: Enum."-reduce/3-lists^foldl/2-0-"/3
    (plausible 0.0.1) lib/plausible_release.ex:55: Plausible.Release.createdb/0
    (stdlib 3.12.1) erl_eval.erl:680: :erl_eval.do_apply/6
    (elixir 1.10.3) lib/code.ex:341: Code.eval_string_with_error_handling/3

When I run the same config on the separate test server as mentioned above, the logs show the errors only since the postgres and clickhouse databases do not exist for the first time(I can login and access the Plausible dashboard now through my browser)…but unsure about the bottom two lines:

Loading plausible..
Starting dependencies..
Starting repos..
create Plausible.Repo database if it doesn't exist
04:26:59.652 [error] Postgrex.Protocol (#PID<0.238.0>) failed to connect: ** (Postgrex.Error) FATAL 3D000 (invalid_catalog_name) database "plausible_db" does not exist
04:26:59.652 [error] Postgrex.Protocol (#PID<0.237.0>) failed to connect: ** (Postgrex.Error) FATAL 3D000 (invalid_catalog_name) database "plausible_db" does not exist
04:26:59.828 [error] Clickhousex.Protocol (#PID<0.244.0>) failed to connect: ** (ErlangError) Erlang error: "Code: 81, e.displayText() = DB::Exception: Database plausible_events_db doesn't exist (version 20.9.3.45 (official build))\n"
04:26:59.829 [error] Clickhousex.Protocol (#PID<0.245.0>) failed to connect: ** (ErlangError) Erlang error: "Code: 81, e.displayText() = DB::Exception: Database plausible_events_db doesn't exist (version 20.9.3.45 (official build))\n"
create Plausible.ClickhouseRepo database if it doesn't exist
Creation of Db successful!
Loading plausible..
Starting dependencies..
Starting repos..
Running migrations for Elixir.Plausible.Repo
Running migrations for Elixir.Plausible.ClickhouseRepo
Migrations successful!
Loading plausible..
Starting dependencies..
Starting repos..
Admin user created successful!
Loading plausible..
Starting dependencies..
Starting repos..
create Plausible.Repo database if it doesn't exist
create Plausible.ClickhouseRepo database if it doesn't exist
Creation of Db successful!
Loading plausible..
Starting dependencies..
Starting repos..
Running migrations for Elixir.Plausible.Repo
Running migrations for Elixir.Plausible.ClickhouseRepo
Migrations successful!
Loading plausible..
Starting dependencies..
Starting repos..
Admin user already exists. I won't override, bailing
11:27:26.636 [error] Clickhousex.Protocol (#PID<0.4269.0>) disconnected: ** (Clickhousex.Error) closed
 4:15:13.941 [error] Clickhousex.Protocol (#PID<0.4261.0>) disconnected: ** (Clickhousex.Error) closed
Database plausible_events_db doesn't exist

Not sure if it can’t access your DB or if it really doesn’t exist.
Also you should avoid to expose your databases through your “common-network” as it’s set to external

Thanks for the suggestion for the networks…your traefik based reference was helpful. I revised the docker-compose files but still getting errors:

Loading plausible..
Starting dependencies..
Starting repos..
create Plausible.Repo database if it doesn't exist
08:22:07.750 [error] Postgrex.Protocol (#PID<0.238.0>) failed to connect: ** (Postgrex.Error) FATAL 3D000 (invalid_catalog_name) database "plausible_db" does not exist
08:22:07.750 [error] Postgrex.Protocol (#PID<0.237.0>) failed to connect: ** (Postgrex.Error) FATAL 3D000 (invalid_catalog_name) database "plausible_db" does not exist
08:22:07.939 [error] Clickhousex.Protocol (#PID<0.244.0>) failed to connect: ** (ErlangError) Erlang error: "Code: 81, e.displayText() = DB::Exception: Database plausible_events_db doesn't exist (version 20.6.4.44 (official build))\n"
08:22:07.939 [error] Clickhousex.Protocol (#PID<0.245.0>) failed to connect: ** (ErlangError) Erlang error: "Code: 81, e.displayText() = DB::Exception: Database plausible_events_db doesn't exist (version 20.6.4.44 (official build))\n"
create Plausible.ClickhouseRepo database if it doesn't exist
08:22:08.052 [error] GenServer #PID<0.264.0> terminating
** (RuntimeError) Code: 81, e.displayText() = DB::Exception: Database `` doesn't exist (version 20.6.4.44 (official build))

    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
08:22:08.056 [error] GenServer #PID<0.265.0> terminating
** (RuntimeError) Code: 81, e.displayText() = DB::Exception: Database `` doesn't exist (version 20.6.4.44 (official build))

    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
08:22:08.059 [error] GenServer #PID<0.266.0> terminating
** (RuntimeError) Code: 81, e.displayText() = DB::Exception: Database `` doesn't exist (version 20.6.4.44 (official build))

    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
08:22:08.061 [error] GenServer #PID<0.267.0> terminating
** (RuntimeError) Code: 81, e.displayText() = DB::Exception: Database `` doesn't exist (version 20.6.4.44 (official build))

    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
** (MatchError) no match of right hand side value: {:error, "killed"}
    (plausible 0.0.1) lib/plausible_release.ex:56: anonymous fn/2 in Plausible.Release.createdb/0
    (elixir 1.10.3) lib/enum.ex:2111: Enum."-reduce/3-lists^foldl/2-0-"/3
    (plausible 0.0.1) lib/plausible_release.ex:55: Plausible.Release.createdb/0
    (stdlib 3.12.1) erl_eval.erl:680: :erl_eval.do_apply/6
    (elixir 1.10.3) lib/code.ex:341: Code.eval_string_with_error_handling/3
Loading plausible..
Starting dependencies..
Starting repos..
create Plausible.Repo database if it doesn't exist
create Plausible.ClickhouseRepo database if it doesn't exist
08:22:21.530 [error] Clickhousex.Protocol (#PID<0.245.0>) failed to connect: ** (ErlangError) Erlang error: "Code: 81, e.displayText() = DB::Exception: Database plausible_events_db doesn't exist (version 20.6.4.44 (official build))\n"
08:22:21.530 [error] Clickhousex.Protocol (#PID<0.244.0>) failed to connect: ** (ErlangError) Erlang error: "Code: 81, e.displayText() = DB::Exception: Database plausible_events_db doesn't exist (version 20.6.4.44 (official build))\n"
08:22:21.530 [error] GenServer #PID<0.265.0> terminating
** (RuntimeError) Code: 81, e.displayText() = DB::Exception: Database `` doesn't exist (version 20.6.4.44 (official build))

    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
08:22:21.535 [error] GenServer #PID<0.266.0> terminating
** (RuntimeError) Code: 81, e.displayText() = DB::Exception: Database `` doesn't exist (version 20.6.4.44 (official build))

    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
08:22:21.538 [error] GenServer #PID<0.267.0> terminating
** (RuntimeError) Code: 81, e.displayText() = DB::Exception: Database `` doesn't exist (version 20.6.4.44 (official build))

    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
08:22:21.542 [error] GenServer #PID<0.268.0> terminating
** (RuntimeError) Code: 81, e.displayText() = DB::Exception: Database `` doesn't exist (version 20.6.4.44 (official build))

    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
** (MatchError) no match of right hand side value: {:error, "killed"}
    (plausible 0.0.1) lib/plausible_release.ex:56: anonymous fn/2 in Plausible.Release.createdb/0
    (elixir 1.10.3) lib/enum.ex:2111: Enum."-reduce/3-lists^foldl/2-0-"/3
    (plausible 0.0.1) lib/plausible_release.ex:55: Plausible.Release.createdb/0
    (stdlib 3.12.1) erl_eval.erl:680: :erl_eval.do_apply/6
    (elixir 1.10.3) lib/code.ex:341: Code.eval_string_with_error_handling/3

Here’s my revised docker-compose file:

version: "3.3"
services:
  mail:
    image: bytemark/smtp
    restart: always

  plausible_db:
    image: postgres:12
    volumes:
      - db-data:/var/lib/postgresql/data
    environment:
      - POSTGRES_PASSWORD=postgres
    restart: always
    networks:
      - internal

  plausible_events_db:
    image: yandex/clickhouse-server:latest
    volumes:
      - event-data:/var/lib/clickhouse
    ulimits:
      nofile:
        soft: 262144
        hard: 262144
    restart: always
    networks:
      - internal

  plausible:
    #build:
      #dockerfile: "./Dockerfile.custom"
      #context: '.'
    image: plausible/analytics:latest
    command: sh -c "sleep 10 && /entrypoint.sh db createdb && /entrypoint.sh db migrate && /entrypoint.sh db init-admin && /entrypoint.sh run"
    depends_on:
      - plausible_db
      - plausible_events_db
      - mail
    env_file:
      - plausible-conf.env
    restart: always
    networks:
      - internal
      - common-network

volumes:
  db-data:
    driver: local
  event-data:
    driver: local
  geoip:
    driver: local

networks:
  common-network:
    external: true
  internal:
    external: false

When I first tried it on the test server, by mistake I forgot to add the “internal” network to the plausible service and then I was getting similar errors:

Loading plausible..
Starting dependencies..
Starting repos..
create Plausible.Repo database if it doesn't exist
07:38:48.951 [error] Postgrex.Protocol (#PID<0.238.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
07:38:48.951 [error] Postgrex.Protocol (#PID<0.237.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
07:38:48.951 [error] GenServer #PID<0.255.0> terminating
** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
** (MatchError) no match of right hand side value: {:error, "killed"}
    (plausible 0.0.1) lib/plausible_release.ex:56: anonymous fn/2 in Plausible.Release.createdb/0
    (elixir 1.10.3) lib/enum.ex:2111: Enum."-reduce/3-lists^foldl/2-0-"/3
    (plausible 0.0.1) lib/plausible_release.ex:55: Plausible.Release.createdb/0
    (stdlib 3.12.1) erl_eval.erl:680: :erl_eval.do_apply/6
    (elixir 1.10.3) lib/code.ex:341: Code.eval_string_with_error_handling/3
Loading plausible..
Starting dependencies..
Starting repos..
create Plausible.Repo database if it doesn't exist
07:39:02.754 [error] Postgrex.Protocol (#PID<0.238.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
07:39:02.754 [error] Postgrex.Protocol (#PID<0.237.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
07:39:02.763 [error] GenServer #PID<0.255.0> terminating
** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
** (MatchError) no match of right hand side value: {:error, "killed"}
    (plausible 0.0.1) lib/plausible_release.ex:56: anonymous fn/2 in Plausible.Release.createdb/0
    (elixir 1.10.3) lib/enum.ex:2111: Enum."-reduce/3-lists^foldl/2-0-"/3
    (plausible 0.0.1) lib/plausible_release.ex:55: Plausible.Release.createdb/0
    (stdlib 3.12.1) erl_eval.erl:680: :erl_eval.do_apply/6
    (elixir 1.10.3) lib/code.ex:341: Code.eval_string_with_error_handling/3
Loading plausible..
Starting dependencies..
Starting repos..
create Plausible.Repo database if it doesn't exist
07:39:16.334 [error] Postgrex.Protocol (#PID<0.238.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
07:39:16.334 [error] Postgrex.Protocol (#PID<0.237.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
07:39:16.372 [error] GenServer #PID<0.255.0> terminating
** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
** (MatchError) no match of right hand side value: {:error, "killed"}
    (plausible 0.0.1) lib/plausible_release.ex:56: anonymous fn/2 in Plausible.Release.createdb/0
    (elixir 1.10.3) lib/enum.ex:2111: Enum."-reduce/3-lists^foldl/2-0-"/3
    (plausible 0.0.1) lib/plausible_release.ex:55: Plausible.Release.createdb/0
    (stdlib 3.12.1) erl_eval.erl:680: :erl_eval.do_apply/6
    (elixir 1.10.3) lib/code.ex:341: Code.eval_string_with_error_handling/3
Loading plausible..
Starting dependencies..
Starting repos..
create Plausible.Repo database if it doesn't exist
07:39:30.089 [error] Postgrex.Protocol (#PID<0.238.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
07:39:30.089 [error] Postgrex.Protocol (#PID<0.237.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
07:39:30.092 [error] GenServer #PID<0.255.0> terminating
** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
** (MatchError) no match of right hand side value: {:error, "killed"}
    (plausible 0.0.1) lib/plausible_release.ex:56: anonymous fn/2 in Plausible.Release.createdb/0
    (elixir 1.10.3) lib/enum.ex:2111: Enum."-reduce/3-lists^foldl/2-0-"/3
    (plausible 0.0.1) lib/plausible_release.ex:55: Plausible.Release.createdb/0
    (stdlib 3.12.1) erl_eval.erl:680: :erl_eval.do_apply/6
    (elixir 1.10.3) lib/code.ex:341: Code.eval_string_with_error_handling/3
Loading plausible..
Starting dependencies..
Starting repos..
create Plausible.Repo database if it doesn't exist
07:39:43.981 [error] Postgrex.Protocol (#PID<0.238.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
07:39:43.981 [error] Postgrex.Protocol (#PID<0.237.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
07:39:43.990 [error] GenServer #PID<0.255.0> terminating
** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
** (MatchError) no match of right hand side value: {:error, "killed"}
    (plausible 0.0.1) lib/plausible_release.ex:56: anonymous fn/2 in Plausible.Release.createdb/0
    (elixir 1.10.3) lib/enum.ex:2111: Enum."-reduce/3-lists^foldl/2-0-"/3
    (plausible 0.0.1) lib/plausible_release.ex:55: Plausible.Release.createdb/0
    (stdlib 3.12.1) erl_eval.erl:680: :erl_eval.do_apply/6
    (elixir 1.10.3) lib/code.ex:341: Code.eval_string_with_error_handling/3
Loading plausible..
Starting dependencies..
Starting repos..
create Plausible.Repo database if it doesn't exist
07:39:57.646 [error] Postgrex.Protocol (#PID<0.238.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
07:39:57.646 [error] Postgrex.Protocol (#PID<0.237.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
07:39:57.649 [error] GenServer #PID<0.255.0> terminating
** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
** (MatchError) no match of right hand side value: {:error, "killed"}
    (plausible 0.0.1) lib/plausible_release.ex:56: anonymous fn/2 in Plausible.Release.createdb/0
    (elixir 1.10.3) lib/enum.ex:2111: Enum."-reduce/3-lists^foldl/2-0-"/3
    (plausible 0.0.1) lib/plausible_release.ex:55: Plausible.Release.createdb/0
    (stdlib 3.12.1) erl_eval.erl:680: :erl_eval.do_apply/6
    (elixir 1.10.3) lib/code.ex:341: Code.eval_string_with_error_handling/3
Loading plausible..
Starting dependencies..
Starting repos..
create Plausible.Repo database if it doesn't exist
07:40:11.454 [error] Postgrex.Protocol (#PID<0.238.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
07:40:11.454 [error] Postgrex.Protocol (#PID<0.237.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
07:40:11.487 [error] GenServer #PID<0.255.0> terminating
** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
** (MatchError) no match of right hand side value: {:error, "killed"}
    (plausible 0.0.1) lib/plausible_release.ex:56: anonymous fn/2 in Plausible.Release.createdb/0
    (elixir 1.10.3) lib/enum.ex:2111: Enum."-reduce/3-lists^foldl/2-0-"/3
    (plausible 0.0.1) lib/plausible_release.ex:55: Plausible.Release.createdb/0
    (stdlib 3.12.1) erl_eval.erl:680: :erl_eval.do_apply/6
    (elixir 1.10.3) lib/code.ex:341: Code.eval_string_with_error_handling/3
Loading plausible..
Starting dependencies..
Starting repos..
create Plausible.Repo database if it doesn't exist
07:40:25.488 [error] Postgrex.Protocol (#PID<0.238.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
07:40:25.488 [error] Postgrex.Protocol (#PID<0.237.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
07:40:25.500 [error] GenServer #PID<0.255.0> terminating
** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
** (MatchError) no match of right hand side value: {:error, "killed"}
    (plausible 0.0.1) lib/plausible_release.ex:56: anonymous fn/2 in Plausible.Release.createdb/0
    (elixir 1.10.3) lib/enum.ex:2111: Enum."-reduce/3-lists^foldl/2-0-"/3
    (plausible 0.0.1) lib/plausible_release.ex:55: Plausible.Release.createdb/0
    (stdlib 3.12.1) erl_eval.erl:680: :erl_eval.do_apply/6
    (elixir 1.10.3) lib/code.ex:341: Code.eval_string_with_error_handling/3
Loading plausible..
Starting dependencies..
Starting repos..
create Plausible.Repo database if it doesn't exist
07:40:39.075 [error] Postgrex.Protocol (#PID<0.238.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
07:40:39.075 [error] Postgrex.Protocol (#PID<0.237.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
07:40:39.123 [error] GenServer #PID<0.255.0> terminating
** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
** (MatchError) no match of right hand side value: {:error, "killed"}
    (plausible 0.0.1) lib/plausible_release.ex:56: anonymous fn/2 in Plausible.Release.createdb/0
    (elixir 1.10.3) lib/enum.ex:2111: Enum."-reduce/3-lists^foldl/2-0-"/3
    (plausible 0.0.1) lib/plausible_release.ex:55: Plausible.Release.createdb/0
    (stdlib 3.12.1) erl_eval.erl:680: :erl_eval.do_apply/6
    (elixir 1.10.3) lib/code.ex:341: Code.eval_string_with_error_handling/3
Loading plausible..
Starting dependencies..
Starting repos..
create Plausible.Repo database if it doesn't exist
07:40:53.025 [error] Postgrex.Protocol (#PID<0.238.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
07:40:53.025 [error] Postgrex.Protocol (#PID<0.237.0>) failed to connect: ** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
07:40:53.057 [error] GenServer #PID<0.255.0> terminating
** (DBConnection.ConnectionError) tcp connect (plausible_db:5432): non-existing domain - :nxdomain
    (db_connection 2.2.2) lib/db_connection/connection.ex:87: DBConnection.Connection.connect/2
    (connection 1.0.4) lib/connection.ex:622: Connection.enter_connect/5
    (stdlib 3.12.1) proc_lib.erl:249: :proc_lib.init_p_do_apply/3
Last message: nil
** (MatchError) no match of right hand side value: {:error, "killed"}
    (plausible 0.0.1) lib/plausible_release.ex:56: anonymous fn/2 in Plausible.Release.createdb/0
    (elixir 1.10.3) lib/enum.ex:2111: Enum."-reduce/3-lists^foldl/2-0-"/3
    (plausible 0.0.1) lib/plausible_release.ex:55: Plausible.Release.createdb/0
    (stdlib 3.12.1) erl_eval.erl:680: :erl_eval.do_apply/6
    (elixir 1.10.3) lib/code.ex:341: Code.eval_string_with_error_handling/3

Adding the “internal” network fixed it on the test server but the issue still persists on the server I’m trying to run it on.

Perhaps for some reason at the first attempt, the databases are not getting created like it does on the test server…maybe related to the docker networks…not sure as the other apps run fine under the same Nginx container…I also tried removing the older plausible volumes after backup to make sure it can be run as a fresh instance but still can’t get it to work :persevere:.

It got fixed after a huge amount of troubleshooting and pruning of older plausible images and related dangling content. This was due to the new changes in clickhouse environment variables that are now hardcoded into the docker image. But I’m really glad that it’s finally solved! Such a beautiful piece of software really needs to have thorough documentation and design for faster and easier deployment.