[Solved] Mongo URL format for Galaxy deployment

I’m deploying a Meteor app on Galaxy for the first time and cannot connect to MongoDB Atlas. Somewhere along the way, I saw meteor in my databases on Atlas, but then recreated my cluster and can’t figure out how I did it the first time.

I can connect to MongoDB through Mongo Shell using the following (provided by MongoDB support):

mongo "mongodb://<host1>:27017,<host2>:27017,<host3>:27017/<db_name>?replicaSet=<replica_set_name>" --ssl --authenticationDatabase admin  --username <username> --password <password>

I tried the following equivalent string for the Mongo URL in my settings.json:

mongodb://<username>:<password>@<host1>:27017,<host2>:27017,<host3>:27017/<db_name>?authSource=admin&replicaSet=<replica_set_name>

But when I deploy my app, I get:

Error: Could not locate any valid servers in initial seed list.

I’ve also tried using the connection string provided by Atlas (also matching Deploy app - Galaxy and Atlas:Mongodb):

mongodb+srv://<username>:<password>@<host>/<db_name>?retryWrites=true&w=majority

But this just returns:

Error: URL must be in the format mongodb://user:pass@host:port/dbname

I don’t know if Galaxy is not recognizing the"+srv" but that always results in an “incorrect format” error.

RESOLVED, WITH HELP FROM MONGODB ATLAS SUPPORT:

"MONGO_URL": "mongodb://:@host1:27017,host2:27017,host3:27017/?ssl=true&replicaSet=&authSource=admin&retryWrites=true&w=majority",

2 Likes

Was just about to reply. As far as I know Meteor does not yet support the new ‘srv’ Mongo connection string. I’d assume it boils down to the version of node Meteor is using. From Atlas you can select the older type connection strings by choosing an older node version, which will then produce the string you received from support.

I very much hope this will get sorted with a Meteor update soon.

1 Like

Glad you got this fixed. I had a quick look and had no idea why it wouldn’t work for you.

Thanks for reporting back with a solution!

I’m pretty sure it was an error somewhere in here: ?ssl=true&replicaSet=&authSource=admin&retryWrites=true&w=majority because I’m pretty had tried the preceding text already.

I just did a test and the srv Mongo URL format seems to work now in Meteor 1.10.2 connecting to Atlas.