Can't connect my local meteor mongoDB to Metabase in Docker

So I was following the tutorial to setup Metabase with Docker but I can't add my local mongo database. I'm getting this error in Docker logs:

08-18 11:36:50 ERROR api.database :: Cannot connect to Database
java.lang.Exception: Timed out after 3000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:3001, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]
	at metabase.driver.util$can_connect_with_details_QMARK_.invokeStatic(util.clj:40)
	at metabase.driver.util$can_connect_with_details_QMARK_.doInvoke(util.clj:23)
	at clojure.lang.RestFn.invoke(RestFn.java:442)
	at metabase.api.database$test_database_connection.invokeStatic(database.clj:408)
	at metabase.api.database$test_database_connection.doInvoke(database.clj:398)
	at clojure.lang.RestFn.invoke(RestFn.java:464)
	at metabase.api.setup$fn__66737.invokeStatic(setup.clj:139)
	at metabase.api.setup$fn__66737.invoke(setup.clj:130)
	at compojure.core$wrap_response$fn__1993.invoke(core.clj:160)
	at compojure.core$wrap_route_middleware$fn__1977.invoke(core.clj:132)
	at compojure.core$wrap_route_info$fn__1982.invoke(core.clj:139)
	at compojure.core$wrap_route_matches$fn__1986.invoke(core.clj:151)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$wrap_route_matches$fn__1986.invoke(core.clj:152)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$wrap_route_matches$fn__1986.invoke(core.clj:153)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005.invoke(core.clj:200)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005.invoke(core.clj:200)
	at compojure.core$make_context$handler__2033.invoke(core.clj:287)
	at compojure.core$make_context$fn__2035.invoke(core.clj:296)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$make_context$fn__2035.invoke(core.clj:297)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$make_context$fn__2035.invoke(core.clj:297)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$make_context$fn__2035.invoke(core.clj:297)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$make_context$fn__2035.invoke(core.clj:297)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$make_context$fn__2035.invoke(core.clj:297)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$make_context$fn__2035.invoke(core.clj:297)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$make_context$fn__2035.invoke(core.clj:297)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$make_context$fn__2035.invoke(core.clj:297)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$make_context$fn__2035.invoke(core.clj:297)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$make_context$fn__2035.invoke(core.clj:297)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$make_context$fn__2035.invoke(core.clj:297)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$make_context$fn__2035.invoke(core.clj:297)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$make_context$fn__2035.invoke(core.clj:297)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$make_context$fn__2035.invoke(core.clj:297)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$make_context$fn__2035.invoke(core.clj:297)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$make_context$fn__2035.invoke(core.clj:297)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$make_context$fn__2035.invoke(core.clj:297)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$make_context$fn__2035.invoke(core.clj:297)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$make_context$fn__2035.invoke(core.clj:297)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$make_context$fn__2035.invoke(core.clj:297)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$make_context$fn__2035.invoke(core.clj:297)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$make_context$fn__2035.invoke(core.clj:297)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$make_context$fn__2035.invoke(core.clj:297)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$make_context$fn__2035.invoke(core.clj:297)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$make_context$fn__2035.invoke(core.clj:297)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005.invoke(core.clj:200)
	at clojure.lang.AFn.applyToHelper(AFn.java:160)
	at clojure.lang.AFn.applyTo(AFn.java:144)
	at clojure.core$apply.invokeStatic(core.clj:665)
	at clojure.core$apply.invoke(core.clj:660)
	at metabase.routes$fn__70010$fn__70011.doInvoke(routes.clj:56)
	at clojure.lang.RestFn.invoke(RestFn.java:436)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005.invoke(core.clj:200)
	at compojure.core$make_context$handler__2033.invoke(core.clj:287)
	at compojure.core$make_context$fn__2035.invoke(core.clj:296)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$wrap_route_matches$fn__1986.invoke(core.clj:153)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$wrap_route_matches$fn__1986.invoke(core.clj:153)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005$f__2006$respond_SINGLEQUOTE___2007.invoke(core.clj:197)
	at compojure.core$wrap_route_matches$fn__1986.invoke(core.clj:153)
	at compojure.core$routes$fn__2005$f__2006.invoke(core.clj:198)
	at compojure.core$routes$fn__2005.invoke(core.clj:200)
	at metabase.middleware.exceptions$catch_uncaught_exceptions$fn__68580.invoke(exceptions.clj:96)
	at metabase.middleware.exceptions$catch_api_exceptions$fn__68577.invoke(exceptions.clj:84)
	at metabase.middleware.log$log_api_call$fn__70458$fn__70459.invoke(log.clj:197)
	at toucan.db$_do_with_call_counting.invokeStatic(db.clj:216)
	at toucan.db$_do_with_call_counting.invoke(db.clj:209)
	at metabase.middleware.log$log_api_call$fn__70458.invoke(log.clj:191)
	at metabase.middleware.security$add_security_headers$fn__68543.invoke(security.clj:121)
	at metabase.middleware.json$wrap_json_body$fn__70161.invoke(json.clj:64)
	at metabase.middleware.json$wrap_streamed_json_response$fn__70179.invoke(json.clj:100)
	at ring.middleware.keyword_params$wrap_keyword_params$fn__70759.invoke(keyword_params.clj:55)
	at ring.middleware.params$wrap_params$fn__70775.invoke(params.clj:69)
	at metabase.middleware.misc$maybe_set_site_url$fn__70489.invoke(misc.clj:59)
	at metabase.middleware.session$bind_current_user$fn__65036$fn__65037.invoke(session.clj:204)
	at metabase.middleware.session$do_with_current_user.invokeStatic(session.clj:186)
	at metabase.middleware.session$do_with_current_user.invoke(session.clj:178)
	at metabase.middleware.session$bind_current_user$fn__65036.invoke(session.clj:203)
	at metabase.middleware.session$wrap_current_user_info$fn__65023.invoke(session.clj:169)
	at metabase.middleware.session$wrap_session_id$fn__65011.invoke(session.clj:127)
	at metabase.middleware.auth$wrap_api_key$fn__68485.invoke(auth.clj:27)
	at ring.middleware.cookies$wrap_cookies$fn__70679.invoke(cookies.clj:216)
	at metabase.middleware.misc$add_content_type$fn__70474.invoke(misc.clj:28)
	at metabase.middleware.misc$disable_streaming_buffering$fn__70497.invoke(misc.clj:76)
	at ring.middleware.gzip$wrap_gzip$fn__70721.invoke(gzip.clj:86)
	at metabase.middleware.ssl$redirect_to_https_middleware$fn__70510.invoke(ssl.clj:39)
	at metabase.server$async_proxy_handler$fn__70236.invoke(server.clj:72)
	at metabase.server.proxy$org.eclipse.jetty.server.handler.AbstractHandler$ff19274a.handle(Unknown Source)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
	at org.eclipse.jetty.server.Server.handle(Server.java:500)
	at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:383)
	at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:547)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:375)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:273)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:103)
	at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:117)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:336)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:313)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:171)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:129)
	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:375)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:806)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:938)
	at java.base/java.lang.Thread.run(Unknown Source)
Caused by: com.mongodb.MongoTimeoutException: Timed out after 3000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:3001, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]
	at com.mongodb.internal.connection.BaseCluster.getDescription(BaseCluster.java:179)
	at com.mongodb.internal.connection.SingleServerCluster.getDescription(SingleServerCluster.java:41)
	at com.mongodb.client.internal.MongoClientDelegate.getConnectedClusterDescription(MongoClientDelegate.java:136)
	at com.mongodb.client.internal.MongoClientDelegate.createClientSession(MongoClientDelegate.java:94)
	at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.getClientSession(MongoClientDelegate.java:249)
	at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:172)
	at com.mongodb.client.internal.MongoClientDelegate$DelegateOperationExecutor.execute(MongoClientDelegate.java:161)
	at com.mongodb.DB.executeCommand(DB.java:774)
	at com.mongodb.DB.command(DB.java:520)
	at com.mongodb.DB.command(DB.java:536)
	at com.mongodb.DB.command(DB.java:491)
	at monger.core$command.invokeStatic(core.clj:251)
	at monger.core$command.invoke(core.clj:242)
	at monger.command$db_stats.invokeStatic(command.clj:71)
	at monger.command$db_stats.invoke(command.clj:69)
	at metabase.driver.mongo$eval2411$fn__2412$f__1826__auto____2413.invoke(mongo.clj:57)
	at metabase.driver.mongo.util$_with_mongo_connection$fn__1817.invoke(util.clj:228)
	at metabase.util.ssh$with_ssh_tunnel_STAR_.invokeStatic(ssh.clj:151)
	at metabase.util.ssh$with_ssh_tunnel_STAR_.invoke(ssh.clj:138)
	at metabase.driver.mongo.util$_with_mongo_connection.invokeStatic(util.clj:222)
	at metabase.driver.mongo.util$_with_mongo_connection.invoke(util.clj:217)
	at metabase.driver.mongo$eval2411$fn__2412.invoke(mongo.clj:56)
	at clojure.lang.MultiFn.invoke(MultiFn.java:234)
	at metabase.driver.util$can_connect_with_details_QMARK_$fn__22482.invoke(util.clj:35)
	at metabase.util$do_with_timeout$fn__10195.invoke(util.clj:310)
	at clojure.core$binding_conveyor_fn$fn__5754.invoke(core.clj:2030)
	at clojure.lang.AFn.call(AFn.java:18)
	at java.base/java.util.concurrent.FutureTask.run(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	... 1 more
08-18 11:36:50 DEBUG middleware.log :: POST /api/setup/validate 400 3.0 s (0 DB calls) 
{:errors
 {:dbname
  "Timed out after 3000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=localhost:3001, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketOpenException: Exception opening socket}, caused by {java.net.ConnectException: Connection refused (Connection refused)}}]"}}

My meteor database is located at localhost:3001 and its running. I also try using the Docker bridge IP instead of localhost but it gives me the same error. Am I doing something wrong or need an extra step? Thanks!

Hi @eymike
You need to make sure that your Mongo is available on interfaces that are accessible from the Metabase container.
If it listens on all interfaces, then Metabase should be able to see it through the host IP.
You’ll likely find better help on stackoverflow.com or similar forums, since it a general Docker networking question and not specific to Metabase.

Thanks for the quick answer @flamber but I couldn’t manage to setup Docker properly so I ended up running Metabase with .jar method and it worked.

Use host.docker.internal:3001 as connection url