MongoDB - can publicly connect to single instance but not replica set.

sa-webbPRO

a year ago

Hello, I am wondering as to why I can connect to a single instance of MongoDB publicly (e.g. locally via MongoDB Compass) but I cannot do the same with my replica set. I'm certain that my connection string is correct so I believe it is networking/security related.

Does anyone have any advice? I need to migrate the data from my single instance to my replica set but again cannot connect.

Thanks

Solved

7 Replies

a year ago

Where is the single instance of mongo hosted and where is the replica set hosted?


Status changed to Awaiting User Response christian 11 months ago


sa-webbPRO

a year ago

I'm sorry if I do not understand - but they are all in US-East? If it helps - my replica set is from this repository https://github.com/railwayapp-templates/mongo-replica-set and my mongodb instance is the default template one.


Status changed to Awaiting Railway Response railway[bot] 11 months ago


a year ago

A mongo replica set on Altas uses a SRV record to tell the client what the addresses of the 3 (or more) replicas are, this method is not applicable on Railway so your client needs to be aware of the 3 separate addresses of each replica service.


sa-webbPRO

a year ago

So I cannot use a single string like this? I'm just a bit confused, thank you for your quick responses and patience.

"mongodb://<username>:<password>@<public_networking_host1>:<public_networking_port1>,<..2>,<..3>/?replicaSet=<replica_set_name>"


a year ago

That format doesn't even look like a valid URL, at least I've never seen one like it, so I'm gonna say no.


sa-webbPRO

a year ago

Gotcha thanks
.

Maybe removing the credentials make it look bad but that's the exact format my services use that can connect to it just the hosts are the private networking urls.

Like I said, it's just strange to me that I have no special properties and I can connect to my single instance without issue but with that replica set it's as if it's in private-network only mode but I can see in the settings that the public url is enabled.

For context, I'm very new to railway so this is probably just growing pains for me.

Again, thanks for the help!


a year ago

No problem!


Status changed to Solved brody 11 months ago


MongoDB - can publicly connect to single instance but not replica set. - Railway Help Station