Customizable connection string for application database setup (sslmode)

Hi,

I’m trying to set up the metabase application database using our postgres instance.
Unfortunately this postgres instance runs in ssl mode which in turn means I have to
set the query parameter sslmode=require to get a valid connection string.

Is there any mechanism, hack or env var to be set to set additional jdbc options?
Setting up a database via the web frontend is no problem it only effects the initialization of
the applications meta database in the setup process…

BTW: I’m running metabase with docker, so I was using the installation guide Running on Docker.

Log says:

INFO metabase.db :: Verifying postgres Database Connection …
ERROR metabase.driver :: Failed to connect to database: org.postgresql.util.PSQLException: FATAL: no pg_hba.conf entry for host “xxx.xxx.xxx.xxx”, user “xxx”, database “metabase”, SSL off

Cheers

Hi,
Were you able to figure out solution for this issue?
I am facing a similar issue with Postgres (on RDS), though standalone installation of postgres on a cloud machine gets connected easily.

Hi Sameer,

I figured out that I could not set any SSL specific params in the connection string for the metadata database which you need to store the whole Metabase metadata stuff like tables, collumns, questions as well as permissions and so on.
My solution was, as we run the whole thing in an docker environment on a self hosted server, to spend Metabase its own (dockerized) database, to store its metadata.
With this hack we were able to start Metabase. Within Metabase you will then be able to set up database conncections to your reporting data and actually add additional JDBC connection string options (like sslmode).

It is still not the best and safest solution, but as long as we are running the whole thing in our own datacenter I can live with it.

HTH

Hi folks,

I ran into the same issue as ms5310 — namely, Metabase couldn’t connect to the metadata database because our database provider only supports connections over SSL.

After digging into the Metabase code, I found that there is another environment variable that gets parsed and used before trying the MB_DB_* variables outlined here: https://metabase.com/docs/latest/operations-guide/start.html#configuring-the-metabase-application-database.

This variable is called MB_DB_CONNECTION_URI, which overrides the other variables, and allows you to specify a raw JDBC connection URI. Passing ssl=true as a query string parameter in MB_DB_CONNECTION_URI works as expected and forces the connection to be established over SSL.

2 Likes