I am unable to connect to Mongo Atlas Cluster ( Free Tier) using metabase docker container
You're on version v0.27.0.RC1
Built on 2017-11-17
Branch: release-0.27.0
Hash: 2c0ccb6
I can see the following error in the logs -
Jan 10 06:56:03 ERROR metabase.driver :: Failed to connect to database: com.mongodb.MongoTimeoutException: Timed out after 3000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=primary}. Client view of cluster state is {type=UNKNOWN, servers=[{address=
I can connect to the cluster with shell, RoboMongo, Node.js application.
purposefully remove the actual server name to
I tried migrating from Free tier to a M10 and still facing the same issue/error.
I am able to connect on my local mongodb with SSL, however MongoDB Atlas logs are showing the following in the logs -
2018-01-12T04:00:26.369+0000 I NETWORK [thread1] connection accepted from 183.87.52.130:65485 #17146 (29 connections now open)
2018-01-12T04:00:26.370+0000 I - [conn17025] AssertionException handling request, closing client connection: 17189 The server is configured to only allow SSL connections
2018-01-12T04:00:26.370+0000 I - [conn17025] end connection 183.87.52.130:65485 (29 connections now open)
@ayukidawe I had this same issue for a month now. Since you are connecting to MongoAtlas, connect to your second or third node, anything other than the primary node. In your additional connection string, use readPreference=secondary&replicaSet=your_replSet_name&ssl=true.
Note that if you use read preference as primary or nearest, you will still experience issues.
I tried this, but still getting the same error -
Feb 07 08:13:58 ERROR metabase.driver :: Failed to connect to database: com.mongodb.MongoTimeoutException: Timed out after 3000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=secondary}. Client view of cluster state is {type=REPLICA_SET, servers=[{address=cluster0-shard-00-00-sx29x.mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoCommandException: Command failed with error 8000: 'no SNI name sent, make sure using a MongoDB 3.4+ driver/shell.' on server cluster0-shard-00-00-sx29x.mongodb.net:27017. The full response is { "ok" : 0, "errmsg" : "no SNI name sent, make sure using a MongoDB 3.4+ driver/shell.", "code" : 8000, "codeName" : "AtlasError" }}}]
Feb 07 08:14:01 ERROR metabase.driver :: Failed to connect to database: com.mongodb.MongoTimeoutException: Timed out after 3000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=secondary}. Client view of cluster state is {type=REPLICA_SET, servers=[{address=cluster0-shard-00-00-sx29x.mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketReadException: Prematurely reached end of stream}}]
Which version of Metabase are you using?
I am using Metabase v0.28.0 . Kindly confirm this is the same version you are using.
Also, it doesn't look like you specified the name of your replicaSet.
Hi Jerry,
I upgraded metabase to 0.28.1 and still getting the same error -
Feb 16 06:44:39 ERROR metabase.driver :: Failed to connect to database:
com.mongodb.MongoTimeoutException: Timed out after 3000 ms while waiting
for a server that matches
ReadPreferenceServerSelector{readPreference=secondary}. Client view of
cluster state is {type=REPLICA_SET, servers=[{address=
cluster0-shard-00-01-sx29x.mongodb.net:27017, type=UNKNOWN,
state=CONNECTING, exception={com.mongodb.MongoCommandException: Command
failed with error 8000: 'no SNI name sent, make sure using a MongoDB 3.4+
driver/shell.' on server cluster0-shard-00-01-sx29x.mongodb.net:27017. The
full response is { "ok" : 0, "errmsg" : "no SNI name sent, make sure using
a MongoDB 3.4+ driver/shell.", "code" : 8000, "codeName" : "AtlasError"
}}}] Feb 16 06:44:42 ERROR metabase.driver :: Failed to connect to
database: com.mongodb.MongoTimeoutException: Timed out after 3000 ms while
waiting for a server that matches
ReadPreferenceServerSelector{readPreference=secondary}. Client view of
cluster state is {type=REPLICA_SET, servers=[{address=
cluster0-shard-00-01-sx29x.mongodb.net:27017, type=UNKNOWN,
state=CONNECTING, exception={com.mongodb.MongoSocketReadException:
Prematurely reached end of stream}}] Feb 16 06:44:42 DEBUG
metabase.middleware :: POST /api/database 400 (6 s) (0 DB calls) {:valid
false, :dbname "com.mongodb.MongoTimeoutException: Timed out after 3000 ms
while waiting for a server that matches
ReadPreferenceServerSelector{readPreference=secondary}. Client view of
cluster state is {type=REPLICA_SET, servers=[{address=
cluster0-shard-00-01-sx29x.mongodb.net:27017, type=UNKNOWN,
state=CONNECTING, exception={com.mongodb.MongoSocketReadException:
Prematurely reached end of stream}}]", :message
"com.mongodb.MongoTimeoutException: Timed out after 3000 ms while waiting
for a server that matches
ReadPreferenceServerSelector{readPreference=secondary}. Client view of
cluster state is {type=REPLICA_SET, servers=[{address=
cluster0-shard-00-01-sx29x.mongodb.net:27017, type=UNKNOWN,
state=CONNECTING, exception={com.mongodb.MongoSocketReadException:
Prematurely reached end of stream}}]"}
On Wed, Feb 14, 2018 at 6:18 PM, Jerry Nwabuilo notifications@github.com
wrote:
@ayukidawe https://github.com/ayukidawe I am using Metabase v0.28.0 .
Kindly confirm this is the same version you are using.—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
https://github.com/metabase/metabase/issues/6678#issuecomment-365597211,
or mute the thread
https://github.com/notifications/unsubscribe-auth/Ahp2T_VLbaGQdFp3m-ckFoUGj-aPuSZ8ks5tUtYKgaJpZM4RY5zY
.
Screenshot for configuration.
I gave authentication database as "admin". Even if i remove it , i get same error.
I tried connecting to "test", "admin" or a custom database. But got same error.
I am able to connect to all db's from RoboMongo.
I have enabled access to everywhere from Atlas - security
IP Address | Comment | Status | Actions
-- | -- | -- | --
0.0.0.0/0 (includes your current IP address) | Â | Active
I am experiencing the same issue. I can connect with MongoDB Compass, but can't seem to connect with Metabase
_Atlas [email protected]_
[email protected]_
Having similar issues on the database setup page, e.g. on "save db", trigger connection setting error message com.mongodb.MongoTimeoutException: Timed out after 3000 ms...
. However, my database is correctly connected and I'm running queries successfully on dashboard, pulse, etc.
I'm using similar Metabase config as @silentachiever
Since you are connecting to MongoAtlas, connect to your second or third node, anything other than the primary node. In your additional connection string, use readPreference=secondary&replicaSet=your_replSet_name&ssl=true.
Background:
I have been using Atlas ([email protected]) + [email protected] successfully for over a year. Yesterday upgraded Atlas to [email protected], which broke my Metabase connection. Saw that I needed to upgrade to >0.27 so just upgraded to 0.28.1. Then started seeing error messages. Tried different settings and confirmed IP whitelist ok, however nothing seemed to resolve error message. But when I checked my dashboard I was viewing results despite connection error message.
Hope this helps.
Hi @thedavidprice It's still not working for me for a new M0 instance. Do you know if it's picking up new data for you, or perhaps just cached data from before?
I wrote to MongoDB Atlas team, and this is what they said:
Hi Jonathan,
I tested connecting Metabase to a Free Tier Altas M0 instance, it timed out as the same result as you have mentioned. It looks like it is due to the nature of Free Tier M0 instance being a shared instance and Metabase is incompatible with Atlas Free Tier M0 instance. This is also correlate with Metabase is using the driver which is [not version 3.4 compatible|https://github.com/metabase/metabase/blob/ca3ac52646f62a6d4213da8b8bf1c5686a95ec87/project.clj#L53]. This is particularly important in MongoDB Atlas M0 which uses a proxy layer for the connections.
To summarise, in order to use Metabase with MongoDB Atlas, you can choose to use M10+ instances or wait for Metabase to release the latest version which will be 3.4 compatible. Note that MongoDB 3.4 clusters may not be fully compatible with Metabase till they have the 3.4 compatible release of Metabase is available.
Please let me know if you have any questions.
Best,
Upgraded to M10, and works for me, now. Most likely this is happening because of the proxy layer for connections in M0. So, yeah, seems to be a bug with Metabase or its driver.
cc @ayukidawe
Update from MongoDB
Hi Jonathan,
Great to know that you were able to connect to Metabase after upgrading to an M10 cluster.
The reason for Metabase being unable to make connection to M0 Free Tier or M2/M5 Altas cluster is due to the fact that they are a shared cluster; running on a shared environment. However, Metabase does not have an updated version of the Java driver to support proxy layer connections, more specifically to support the [SNI|https://tools.ietf.org/html/rfc6066#section-3] TLS extension to make the connection to your shared instance.
I hope this helps answer your question, please feel free to let me know should you have additional questions.
@jontsai Ah, to confirm I am indeed using the M10 tier and do not have experience connecting Metabase with a lower Atlas tier.
Any plans on updating the mongodb driver to fix this issue?
Hey Guys,
I dug into this issue and thought id share my findings.
Atlas Connection Prerequisites
- Clients must have support for TLS/SSL to connect to an Atlas cluster.
- Clients must have support for the SNI TLS extension to connect to an Atlas M0 Free Tier or M2/M5 shared starter cluster.
SNI support requires both Java 8 or newer and the 3.6.3 Java driver.
monger version 3.1.0 (latest published which was released 17 Sep 2016) uses the mongodb-driver 3.3.0, the latest head 3.2.0-snapshot uses the mongodb-driver 3.6.0-beta2
I've managed to compiled it with the mongodb-driver updated to 3.6.3 and have deployed it to clojars ([org.clojars.bolamn/monger "3.2.0-SNAPSHOT"])
I've also deployed a docker version of metabase 0.29.2 with the monger dependancies updated (bolamn/metabase-atlas) which should hopefully support Atlas M0 Free Tier or M2/M5 shared starter clusters.
I'm currently testing it at the moment, will report back with my results later.
Any news with this issue?
Has anyone tested if this also happens in a dedicated instance of Mongo Atlas?
@BoLaMN wondering if you had success and, if so, if it would be possible to submit a PR into metabase master?
@sir-gon it seems most of the issues related to free tiers and “shared” plans. My best guess is that you’re in the clear with a dedicated Atlas instance. I’ve continued to use M10 with no problem running latest metabase.
update time 2
my version of monger successfully worked with atlas, two considerations are
setting ssl=true
in the additional options isnt used (eg ssl=true&replicaSet=rs-shard-0&readPreference=secondary) instead it uses the ssl option defined on create as theres a ssl toggle
creating a new database entry and setting the toggle upon create or manually editing the postgres database to set ssl to true should solve alot of peoples issues
moving forward that ssl toggle should be added to the update screen
ive attached the beanstalk setup files pointing at docker pull bolamn/metabase-head:0.30-snap-debug
https://hub.docker.com/r/bolamn/metabase-head/tags/
cheers
@BoLaMN Thanks for passing this along! I'll take a look at implementing what you've done as well.
@BoLaMN could you provide pls a sample of your mongodb atlas parameters? I'm not sure how to pass host and extra parameters
@BoLaMn any ideas here, please. Set up Metabase on elastic beanstalk - tried connecting the free M0 Atlas version (didn't work for obvious reasons). Upgraded the Metabase Elastic Beanstalk version to 3.0. Tried a dedicated Mongo instance - same. Came back to Atlas - upgraded to M10. Same error. Followed this thread. We are reading the secondary cluster with the right settings (readPreference=secondary&replicaSet=cluster0-shard-00-01-xxxxx&ssl=true). Same error. I am not a developer - but trying to set up a serverless environment as far as possible - so simple instructions please.
Do we set up a new beanstalk instance with this your Zip file? Does this apply the fix to Metabase?
My zip points to a modified version of metabase with a the latest head of monger compiled with mongodb-driver 3.8.0 for support for the free atlas cluster.
using &ssl=true is ignored on updates and has to be done on create only, use devtools and have a look at the response back for the database and under details.ssl it has to be true
Thanks @BoLaMN Not sure where you are (still finding my way around the environment - not a techie).
Is devtools in Atlas or Beanstalk?
Looking for idiot proof instructions if you can (don't overestimate the skills level of the idiot)
I upgraded to M10 to get the BI connector enabled - assumed this is how Metabase connects to Atlas. I have enabled the BI Connector - it's not that cheap. Does Metabase use this or bypass it? if it works? If it doesn't use it i will disable it
Still trying options - not sure this helps. If i am on M10 does the ssl=true setting still need fixing?
com.mongodb.MongoTimeoutException: Timed out after 3000 ms while waiting for a server that matches ReadPreferenceServerSelector{readPreference=secondary}. Client view of cluster state is {type=REPLICA_SET, servers=[{address=cluster0-shard-00-01-umkz9.mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketReadException: Prematurely reached end of stream}}]
OK - we finally managed a Metabase connection. Moved away from Atlas and and got Metabase to connect to an Ubuntu instance of Mongo...
I am experiencing the same issue.
Update my jdk from 8u91
to 8u181
fix the issue
I was experiencing the same issue yesterday with metabase docker image but @zhao0 comment helped me (thanks a lot!)
My solution only works for Metabase Docker image, if you want to be able to connect to Atlas Cluster you need to :
Dockerfile
java:openjdk-8-jdk-alpine
to openjdk:8-jdk-alpine
(l.5)java:openjdk-8-jre-alpine
to openjdk:8-jre-alpine
(l.58)nodejs-npm
package because npm is not included anymore in nodejs
package in the following line RUN apk add --update bash nodejs git wget make gettext
docker build .
I forked the repo and change these things in the Dockerfile
but I do not know if tests are needed for things like this to submit a pull request, if somebody want to do it, feel free !
Hope it will help !
same issue here, can we just accept mongo connection string as input?
I haven’t tested, but I believe this PR into monger (metabase mongodb driver) would be a step in the right direction: https://github.com/michaelklishin/monger/pull/175
Looks like monger project has stalled out. Anyone from Metabase able to reach out with a friendly ping to @michaelklishin ?
Any updates on this one? Will it be fixed in 0.31?
@BoLaMN — thank you so much! This fixed my issue with connecting to a MongoDB deployment hosted with compose.io. I'm finally up and running. Would be great to get this into the next official Metabase release, though...
Hey Guys
Just pushed version 0.31.1 to docker with mongodb 3.9.0 driver (docker pull bolamn/metabase-head:0.31.1)
I've committed the changes i make to both metabase and monger to make the updated driver work so maybe someone from the metabase team might fork monger and deploy it to clojar and link it back to the metabase repo
metabase changes
monger changes
attached is also a updated aws elasticbeanstalk zip
cheers
Nice!! Thanks @BoLaMN.
Hey,
I followed @BoLaMN 's instructions which worked quite well. I did create my own metabase docker image with the upgraded monger dependency. However I am not able to connect to a mongoDB Atlas instance. Any ideas how to configure the connection correctly?
So updating the Monger dependency fixes this?
@camsaul I cannot confirm that updating the monger dependency is fixing the issue as it is not working for me
@camsaul in reference to #9030 it looks like @BoLaMN also had to update unit test(s) and made updates to monger directly:
https://github.com/metabase/metabase/issues/6678#issuecomment-441519196
Hope this helps but admittedly these aspects are well over my head. But please consider this either way as gratitude for taking a look at this issue. It's been a sticking point for many of us mongodb'ers for awhile now.
@herrsorgenfrei Do you mean you used this docker image bolamn/metabase-head:0.31.1
?
And which Atlas tier and mongodb version are you using? There's been issues with free tiers that are hopefully fixed with the updated driver -- not sure how the connection settings/strings will be affected. Otherwise you might need to use settings described earlier in this thread. See this example: https://github.com/metabase/metabase/issues/6678#issuecomment-363364465
But mongodb version will be important and I also believe new driver affects whether or not the ssl=true
should be passed. Helpful to look at the connection settings provided by Atlas for your cluster.
Thanks @thedavidprice but there's no need to change Monger at all, we can just swap out the MongoDB driver dependency in Metabase itself.
Fixed by #9030
@thedavidprice I created my own image, but I did all monger and metabase patches as described by @BoLaMN. We're running a M10 4.0.4 cluster.
@herrsorgenfrei unfortunately I don’t have experience with mongo 4 on Atlas. You should be good with the M10 cluster. Hopefuly this at least limits your testing to the string — if you figure out settings assuming many others here would be interested in how you did it.
Lastly, just to make sure, atlas IP whitelist good? (has caused me to slap my forehead more than once…)
@thedavidprice I've checked the security settings multiple times and I am confident, that the IP whitelisting is not an issue at this point.
I will try some more combinations, but for now it's only wild guessing.
@camsaul As you closed this bug, do you have any recommendations how to configure the mongodb connection strings?
@camsaul I’m not sure that was a good idea as the changes I had were against the unreleased monger 3.2.0-SNAPSHOT version not the current 3.1.0 version released in 2016...
@camsaul @BoLaMN looks like monger project lights are back on and has quickly moved to a v3.5 RC-1. See https://github.com/michaelklishin/monger/issues/179
Background on bump from 3.1 to 3.5:
The next release will be 3.5 due to breaking changes in MongoDB server, Java client, CLI tools/admin commands, Ragtime, and core.cache. None of them are major but nonetheless I don't think it's a good idea to use a regular minor version bump.
Does it makes sense include stable monger 3.5 in metabase 0.31.2 release?
Monger 3.5.0 has been released.
@herrsorgenfrei have you been able to to connect to your your 4.0.4 M10 Atlas cluster? I am trying to do the same.
@gitmrlu No, it was not possible. If you have any ideas, let me know.
I didn't buy the mongodb Atlas "BI Connector"-module.
I had the same problem and got the same error , this works for me :
Go to Cluster configuration, in the Security tab then add a new rule 0.0.0.0/0
I am also facing this issue. I tried both Mongo 3.6 and 4.0. For 4.0, tried both M0 and M10.
The errors are almost same as other people here:
readPreference=secondary&ssl=true&replicaSet=<My Replica Set>&authSource=admin
.[conn301] Error receiving request from client: SSLHandshakeFailed: The server is configured to only allow SSL connections. Ending connection from <My Metabase Instance IP>
com.mongodb.MongoTimeoutException: Timed out after 3000 ms while waiting for a server that matches com.mongodb.client.internal.MongoClientDelegate$1@381b8f66. Client view of cluster state is {type=REPLICA_SET, servers=[{address=<My Shard Host And Port>, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketReadException: Prematurely reached end of stream}}]
@camsaul @thedavidprice
I suppose we need to reopen this issue.
I read through this issue and I felt that actually almost none of those using MongoDB Atlas resolved this issue, although some people using compose.io got this resolved.
@tomohiro-n did u read my comments regarding using ssl=true in the connectionstring?
https://github.com/metabase/metabase/issues/6678#issuecomment-405830014
@BoLaMN Thanks for the comment! I did, but I was not sure about as theres a ssl toggle
. I'm using the latest Metabase version v0.32.4 but I cannot find the SSL toggle easily. Could you please clarify where the toggle is?
The below is what I see (I cleared my input though):
@tomohiro-n
I can confirm mongo is working fine for mongodb v4, metabase 0.32, and both paid and free Tiers on Atlas.
Have you checked the Atlas /Security/Whitelist and added IPs?
For Additional Mongo connection string options, try:
ssl=true&replicaSet=<your_db>-shard-0
_Note:_ This string is found via the Atlas Connection settings for your db.
@thedavidprice
Thanks.
So you are saying now ssl=true
isn't ignored? I understood you can confirm it's working fine but there seems to be many people stuck at the same point.
My IP whitelist is good. And the for the connection string, I tried ssl=true&replicaSet=<your_db>-shard-0
too but the same error (Actually <your_db>-shard-0
was what I meant by <My Replica Set>
in my previous comment).
I tried the same host, port user, pass, options from other sources such as Redash, Mongo Shell, my NodeJS sever, etc and all of them can connect to this database. Thus I'm sure I set IP whitelist and options correctly.
Both my Metabase instance and my MongoDB Atlas cluster are located on GCP but I also tried running Metabase locally via Docker. This also resulted in the same error.
Any other advices would be appreciated. I already spent 4+ hours on this so I temporarily need to move away from Metabase for this mongo but will come back as soon as I can find a potential solution.
in devtools what does your database entry return eg. https://cldup.com/DrONZRyhIS.jpg
Also https://github.com/metabase/metabase/blob/14dd7d8b3ebf482e2fe2f004fdec038c29d13808/modules/drivers/mongo/src/metabase/driver/mongo/util.clj#L56 still uses sslEnabled function at the end so if ssl is false it’ll override the connection string
@BoLaMN Thanks! I think I got what you mean.
At /setup
, two POST /api/setup/validate
requests are issued:
details.details.ssl: true
. Response is {"errors":{"dbname":"com.mongodb.MongoTimeoutException: Timed out after 3000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=<Host and Port>, type=UNKNOWN, state=CONNECTING}]"}}
details.details.ssl: false
. Response is {"errors":{"dbname":"com.mongodb.MongoTimeoutException: Timed out after 3000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=<Host and Port>, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketReadException: Prematurely reached end of stream}}]"}}
.After the setup, we can also try to add the database at /admin/databases/create
, and the request is POST /api/database
. It doesn't have ssl
property in the details
object as opposed to the /setup
screen. Of course it does have details.additional-options: "ssl=true&replica...."
though.
So the next question would be, "Even if the ssl=true
in details.additional-options
is ignored, why does the first request with detail.detail.ssl: true
tend to cause a timeout?". It does not happen from other tools or servers to the same MongoDB cluster.
also try ssl=true&replicaSet=<name>-shard-0&readPreference=secondary
and
<name>-shard-00-02-abcde.mongodb.net
as the host
with
Authentication Database: admin
I'm also experiencing issues connecting to Atlas at the moment. I'm running Metabase v0.32.3.
In Atlas, all IPs are whitelisted.
Metabase query string is set to:
ssl=true&replicaSet=<name>-shard-0&readPreference=secondary
When I set host to cluster URL I get this exception
exception={com.mongodb.MongoSocketException: xxxxxx.mongodb.net}, caused by {java.net.UnknownHostException: xxxxxx.mongodb.net}
When I set host to replicaSet URL I get his exception:
exception={com.mongodb.MongoSocketReadException: Prematurely reached end of stream}
Hi,
same issue here:
host:
xxx-xxx.mongodb.net
database name:
xxx
port:
27017
Database username:
xxx
Database password:
xxx
Authentication Database:
admin
Additional Mongo connection string options:
ssl=true&replicaSet=xxx-shard-0&authSource=admin
MongoDB 3.4
Metabase 0.32.4
@BoLaMN
also try ssl=true&replicaSet=
-shard-0&readPreference=secondary
and
-shard-00-02-abcde.mongodb.net as the host
with
Authentication Database: admin
I have already tried these but no luck...
Finally I have a positive update.
At /setup
, I got another error, {"errors":{"dbname":"Connection to '<instance host and port>' successful, but could not connect to DB."}}
with the following parameters.
admin
ssl=true&replicaSet=<cluster name>-shard-0&readPreference=secondary
And then when I changed the user&pass to the one which has read-write access to the database, I passed the validation.
Here's the settings at Atlas. Top one passed and second one failed.
Questions and other facts:
/admin/databases/create
. It needs to be fixed as we cannot add second or more databases.Recommended workarounds regarding the issue that we cannot change the settings or add a new entry later at /admin/databases/create
are also appreciated.
@tomohiro-n im running v0.32.0-snapshot, built on 2018-11-26, branch mongo-atlas, hash 2f76ebe and have 3 databases that were setup via the ui so something changed between then and now
as for the other questions im not able to answer as i dont know clojure nor do i know the codebase that well, might be worth raising a pull request if you wish too as this ones closed.
anyway ill be unwatching this thread from now as i think theres enough to get by, thou i do agree its not the most user friendly setup for mongo atm.
Using the old style connection 2.~ worked for me.
This really strange I already have an app deployed and working with the new connection way
I've also burned several hours on this issue, and still haven't been able to get Metabase to successfully connect to my MongoDB Atlas 4.0 database.
For the host, I've tried using the cluster (xxx-xxx.mongodb.net
) and each of the shards (xxx-shard-00-0x-xxx.mongodb.net
).
For the user, I've tried giving them read only, read+write, and admin access.
My authentication database is set to admin. My connection string is ssl=true&replicaSet=xxx-shard-0&readPreference=secondary
.
It seems that no matter what I do, I get the following connection timeout error:
com.mongodb.MongoTimeoutException: Timed out after 3000 ms while waiting to connect. Client view of cluster state is {type=UNKNOWN, servers=[{address=xxx-shard-00-0x-xxx.mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketReadException: Prematurely reached end of stream}}]
Connecting to my DB with the following command line works:
mongo "mongodb+srv://xxx-xxx.mongodb.net/xxx" --username xxx -pxxx
If anyone has had success connecting Metabase to a MongoDB Atlas 4.0 cluster, please post your full configuration.
I'm on Metabase 0.32.5, which is the current latest version.
This seems to be an issue with Metabase UI. I've just managed to add a new Mongo Atlas instance by connecting directly into the Postgres where my Metabase Config is stored, and added a new database row manually! 🎉
Example of how a details
field in the record looks like:
{"additional-options":"retryWrites=true","ssl":true,"authdb":"admin","port":27017,"dbname":"test","host":"xxxxx-shard-00-00-rerjf.mongodb.net", "tunnel-port":22,"pass":"..........","user":"someUser"}
Then I just went to Admin > Databases > Instances > Sync schema & field values, and voila 👌
connecting directly into the Postgres where my Metabase Config is stored
Is there documentation somewhere on how to do this? Can't find it.
connecting directly into the Postgres where my Metabase Config is stored
Is there documentation somewhere on how to do this? Can't find it.
Sorry, I did not find any documentation about this. My Metabase instance is configured to store stuff into a Postgres db, so what I did is just psql
into the Postgres instance, and updated metabase_database
.
Since this is a closed thread originally started over a year ago, I’d recommend someone currently experiencing issues open a new Issue with details. I am not having any difficulty with connection. But clearly something seems to have spiked for new install with current metabase version. Doubtful these new comments are visable to Metabase dev team.
If you do create an issue, please comment here with link/ID.
Hi all, as @thedavidprice suggested, I've opened a new issue describing this problem: https://github.com/metabase/metabase/issues/9867
If you're still experiencing problems connecting Metabase to a MongoDB Atlas 4.0 cluster, I'd recommend giving that one a 👍
Whoever is not able to do it.
Go to MongoDB Atlas.
Connect Your Application
mongodb://admin:<password>@your-proj-shard-00-00-xxxxx.mongodb.net:27017,your-proj-shard-00-01-xxxxx.mongodb.net:27017,your-proj-shard-00-02-xxxxx.mongodb.net:27017/test?ssl=true&replicaSet=your-proj-shard-0&authSource=admin&retryWrites=true
Now in your metabase for mac app
Host: your-proj-shard-00-00-xxxxx.mongodb.net
Database: test
Port: 27017
Database Username: admin
Database Password: your_password
Database Options: ssl=true&replicaSet= your-proj-shard-0&authSource=admin&retryWrites=true
Metabase tries to change case. Every option is case sensitive so please take care of that.
I was using Metabase for mac app 0.32.5.0
If there are any more versions you need let me know. If you are constantly getting that Server Encountered Error. I suggest you download the docker image that @BoLaMN created and run it and check docker logs of that.
That new mongod+srv URL doesn't work. Don't waste time there.
@SarasArya I tried exactly that, and it doesn't work for me.
com.mongodb.MongoTimeoutException: Timed out after 3000 ms while waiting for a server that matches com.mongodb.client.internal.MongoClientDelegate$1@769e44b0. Client view of cluster state is {type=REPLICA_SET, servers=[{address=MYPROJ-shard-00-00-XXX.mongodb.net:27017, type=UNKNOWN, state=CONNECTING, exception={com.mongodb.MongoSocketReadException: Prematurely reached end of stream}}]
In our case antivirus/firewall is blocking database connection,
Try to disable antivirus/firewall and check again. hope it will work.
I think you have to try IP whitelist default 0.0.0.0/0(for the local test)
I concur with the concept that vjfloyd and akhileshamar95 have stated. It will fix it. It does, however, open up some security risk. My IP address changed here on my home modem, I found out with WhatsMyIp, and it was different than the specific IP address I had previously added to the whitelist on Atlas. Put in the correct (specific) IP address, and back and running. Of course 0.0.0.0/0 fixes it, but it is maybe too open for any requester. Depends on your situation.
I was able to connect after many attempts. Here is what I did.
I tried connecting using the mongo shell, and from the log, I took the connection string and pasted in compass and it worked. From the connection string, I got from the shell, I had to change compressors=disabled
to compressors=zlib
mongodb+srv://<un>:<pw>@prod-aprnd.mongodb.net/test?authSource=admin&compressors=zlib&gssapiServiceName=mongodb&replicaSet=Prod-shard-0&ssl=true
not sure what is wrong with the connection string given at the atlas website and it is
mongodb+srv://<username>:<password>@prod-aprnd.mongodb.net/test
i am facing this error.Error: queryTxt ETIMEOUT cluster0-gv6vq.mongodb.net
at QueryReqWrap.onresolve [as oncomplete] (dns.js:202:19) {
errno: 'ETIMEOUT',
code: 'ETIMEOUT',
syscall: 'queryTxt',
hostname: 'cluster0-gv6vq.mongodb.net'
}
if you are using spring boot, please make sure you've excluded the mongodb out of auto-configuration
Using Google's DNS server 8.8.8.8 and 8.8.4.4 can resolve this issue. In the network settings of your computer add the google DNS.
try add "--password *" to the end of your command
Tried DNS, password... nothing worked, any tips?
Same issue here, can't connect to the cluster, throws queryTxt ESERVFAIL, tried many proposals on this topic :(
@Cfvillarroel Check if a firewall or antivirus is blocking connections.
happens to me when i connect to my iphone's hotspot. (whitelisting IP does not work)
I solved it including in the security configuration in Atlas DB adding my public IP to the list of "IP public" allowed to access Mongo ATLASDB
Most helpful comment
Any plans on updating the mongodb driver to fix this issue?