Meteor cant connect to mongodb atlas srv

I have mongodb atlas using srv

and my meteor project cant connect to it

MONGO_URL=mongodb+srv://username:password@beta-6gxq4.azure.mongodb.net/test?retryWrites=true&w=majority meteor run

is there any way to connect mongodb atlas?

1 Like

Hi, the last commit related to mongo driver, in Meteor 1.10 b5 refers to “Update MongoDB driver to 3.5.2”
SRV is a feature of MongoDB Driver 3.6 https://www.mongodb.com/blog/post/mongodb-3-6-here-to-SRV-you-with-easier-replica-set-connections

It might be that you don’t have a driver to connect in that way which I guess leaves you with the “highly compatible” option to connect the known (old) way, listing all replica sets.

Hi, I use Atlas, looking in my settings.json I have a port number on the MONGO_URL for atlas, port 27017

we324r2e3.mongodb.net:27017

Try that maybe ?

I think there’s some version confusion here.

The MongoDB driver that is updated by Meteor 1.10 is the Node.js driver. The blog post is about “MongoDB 3.6”. MongoDB 3.6 is compatible with Mongo nodejs drivers 3.0 and above.

My own app for example is on Meteor 1.8, using Node.js driver 1.3, and MongoDB 4.2.

That must be why Atlas gives the srv link to those who connect using the nodejs driver version 3.0 or later:

I am confused however why the linked blog post refers sometimes to “MongoDB 3.6” and sometimes to “driver 3.6”, as if those are one and the same thing, which doesn’t seem to be the case.

1 Like

3.6 driver = all official drivers compatible MongoDB 3.6

2 Likes

I went thru this see if this helps:

Hi,
I am also having trouble connecting mongo atlas after mlab service was stopped by Heroku.
I’m unable to connect it on my local meteor app as well as on heroku.
Can anyone help me with this:
set MONGO_URL=mongodb://[username]:[password]@cluster0-shard-00-00-xgnuk.mongodb.net:27017,cluster0-shard-00-01-xgnuk.mongodb.net:27017,cluster0-shard-00-02-xgnuk.mongodb.net:27017/[database]?ssl=true&replicaSet=Cluster0-shard-0&readPreference=primaryPreferred&w=majority&authSource=admin meteor --settings settings.json

MONGO_URL: ‘mongodb+srv://user:password@pampam.tamtam.mongodb.net/meteor?retryWrites=true&w=majority&connectTimeoutMS=60000&socketTimeoutMS=60000’,

Thank you for reply
But everytime it connects to local default mongo db connection on port 3001 not remote one

Ok in Heroku you have Env Vars where you need to specify the Mongo connection. As for the local station in 7 years in the Node environment I still haven’t found a reason to connect a local station to a live DB however, I understand that other people have other needs. This might help you: Connect localhost Meteor JS to remote MongoDB Atlas (2020 tutorial) - YouTube
I suspect you are missing the single quotes.

1 Like

Hi, Finally it’s working.
Now my website is up finally.
Thank you so much for the suggestions. It helps me a lot!!