Error During Migration from H2 to PostgreSQL: "Unable to connect to Metabase H2 DB"

Hello everyone,

I’m attempting to migrate my Metabase setup from H2 to PostgreSQL, following the official documentation. I’m using a Docker container for this process and took a backup of my H2 database before starting the migration.

When I run the migration command:
java -jar metabase.jar load-from-h2 /path/to/metabase.db

I encounter the following error:
clojure.lang.ExceptionInfo: ERROR Set up h2 source database and run migrations...: Unable to connect to Metabase h2 DB. {}
at metabase.cmd.copy$do_step$fn__100134.invoke(copy.clj:34)
at metabase.cmd.copy$do_step.invokeStatic(copy.clj:30)
at metabase.cmd.copy$do_step.invoke(copy.clj:28)
at metabase.cmd.copy$copy_BANG_.invokeStatic(copy.clj:393)
at metabase.cmd.copy$copy_BANG_.invoke(copy.clj:383)
at metabase.cmd.load_from_h2$load_from_h2_BANG_.invokeStatic(load_from_h2.clj:35)
at metabase.cmd.load_from_h2$load_from_h2_BANG_.invoke(load_from_h2.clj:25)
at clojure.lang.Var.invoke(Var.java:384)
at metabase.cmd$load_from_h2.invokeStatic(cmd.clj:74)
at metabase.cmd$load_from_h2.invoke(cmd.clj:68)
at clojure.lang.AFn.applyToHelper(AFn.java:154)
at clojure.lang.AFn.applyTo(AFn.java:144)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.core$apply.invoke(core.clj:662)
at metabase.cmd$run_cmd$fn__107764.invoke(cmd.clj:313)
at metabase.cmd$run_cmd.invokeStatic(cmd.clj:310)
at metabase.cmd$run_cmd.invoke(cmd.clj:300)
at clojure.lang.Var.invoke(Var.java:393)
at metabase.core$run_cmd.invokeStatic(core.clj:193)
at metabase.core$run_cmd.invoke(core.clj:191)
at metabase.core$entrypoint.invokeStatic(core.clj:215)
at metabase.core$entrypoint.doInvoke(core.clj:210)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at clojure.lang.Var.applyTo(Var.java:705)
at clojure.core$apply.invokeStatic(core.clj:667)
at clojure.core$apply.invoke(core.clj:662)
at metabase.bootstrap$main.invokeStatic(bootstrap.clj:31)
at metabase.bootstrap$main.doInvoke(bootstrap.clj:28)
at clojure.lang.RestFn.applyTo(RestFn.java:137)
at metabase.bootstrap.main(Unknown Source)
Caused by: clojure.lang.ExceptionInfo: Unable to connect to Metabase h2 DB. {}
at metabase.db.setup$verify_db_connection$fn__53455.invoke(setup.clj:117)
at metabase.db.setup$verify_db_connection.invokeStatic(setup.clj:115)
at metabase.db.setup$verify_db_connection.invoke(setup.clj:107)
at metabase.db.setup$setup_db_BANG
$fn__53475$fn__53476.invoke(setup.clj:165)
at metabase.util.jvm$do_with_us_locale.invokeStatic(jvm.clj:239)
at metabase.util.jvm$do_with_us_locale.invoke(jvm.clj:225)
at metabase.db.setup$setup_db_BANG
$fn__53475.invoke(setup.clj:161)
at metabase.db.setup$setup_db_BANG_.invokeStatic(setup.clj:160)
at metabase.db.setup$setup_db_BANG_.invoke(setup.clj:153)
at metabase.cmd.copy$copy_BANG_$fn__100326.invoke(copy.clj:394)
at metabase.cmd.copy$do_step$fn__100134.invoke(copy.clj:31)
... 29 more
Caused by: org.h2.jdbc.JdbcSQLNonTransientConnectionException: Database "/home/metabase/metabase.db" not found, and IFEXISTS=true, so we cant auto-create it [90146-214]
at org.h2.message.DbException.getJdbcSQLException(DbException.java:678)
at org.h2.message.DbException.getJdbcSQLException(DbException.java:477)
at org.h2.message.DbException.get(DbException.java:223)
at org.h2.message.DbException.get(DbException.java:199)
at org.h2.engine.Engine.throwNotFound(Engine.java:186)
at org.h2.engine.Engine.openSession(Engine.java:72)
at org.h2.engine.Engine.openSession(Engine.java:222)
at org.h2.engine.Engine.createSession(Engine.java:201)
at org.h2.engine.SessionRemote.connectEmbeddedOrServer(SessionRemote.java:338)
at org.h2.jdbc.JdbcConnection.(JdbcConnection.java:122)
at org.h2.Driver.connect(Driver.java:59)
at java.sql/java.sql.DriverManager.getConnection(Unknown Source)
at java.sql/java.sql.DriverManager.getConnection(Unknown Source)
at metabase.db.data_source.DataSource.getConnection(data_source.clj:79)
at clojure.java.jdbc$get_connection.invokeStatic(jdbc.clj:372)
at clojure.java.jdbc$get_connection.invoke(jdbc.clj:274)
at clojure.java.jdbc$db_query_with_resultset_STAR_.invokeStatic(jdbc.clj:1111)
at clojure.java.jdbc$db_query_with_resultset_STAR_.invoke(jdbc.clj:1093)
at clojure.java.jdbc$query.invokeStatic(jdbc.clj:1182)
at clojure.java.jdbc$query.invoke(jdbc.clj:1144)
at clojure.java.jdbc$query.invokeStatic(jdbc.clj:1160)
at clojure.java.jdbc$query.invoke(jdbc.clj:1144)
at metabase.driver.sql_jdbc.connection$can_connect_with_spec_QMARK_.invokeStatic(connection.clj:349)
at metabase.driver.sql_jdbc.connection$can_connect_with_spec_QMARK_.invoke(connection.clj:346)
at clojure.lang.Var.invoke(Var.java:384)
at metabase.db.setup$verify_db_connection$fn__53455.invoke(setup.clj:115)
... 39 more
Command failed with exception: ERROR Set up h2 source database and run migrations...: Unable to connect to Metabase h2 DB.

It appears that Metabase cannot locate the H2 database file. I've confirmed that the file exists at the specified path and that Docker volumes are correctly set up. Despite this, the error persists.

Has anyone else encountered this issue or have any insights into what might be going wrong? I’d appreciate any guidance or solutions you might have!

Thank you!

the h2 files are named

regards,
Luis

These are the default names that I received from the database and I follow the path structure which I got from the official documentation of Metabase regarding the H2 to Postgres migrations. Here, are some data that I shared and I followed this method, however faced the error.

java -jar metabase.jar load-from-h2 /path/to/metabase.db # do not include .mv.db

Note that the file name of the database file itself might be /path/to/metabase.db.mv.db , but when running the load-from-h2 command, you need to truncate the path to /path/to/metabase.db .

Here is the reference link from where I got this information and also implemented it: