Connecting the same MongoDB Atlas database to a local app and a railway deployed app

I have developed a web-app using Express (Node.js/JavaScript) web frameworks, initially following a MDN tutorial but flying solo now. There is an MongoDB Atlas database, for the data, connected to the app and working very well. On deploying the app via Railway, without a database service, I expected to be able to connect to the same Atlas database using the same connection script "mongodb+srv://<username>:<password>@crdata.mg0nclu.mongodb.net/courseLZ?retryWrites=true&w=majority". This failed to connect even though I had a white-listed IP (0.0.0.0/0).

Many hours of reading and experimenting followed including replacing the Atlas DB with a MongoDB service in the Railway container. Long story short over 24 hours after having added a white-list IP to my Atlas account the app on Railway connected to the Atlas database!! Clearly my problem is resolved but I thought it might be a good discussion topic for my first post on this forum. Thanks for “listening”.

2 Likes

Hey, where do you find your Railway outbound IP’s to add to the Atlas database?

Thanks for pointing me into right direction. In my case it was insta-change on atlas part and everything worked. I’m on free tier.

This really saved me a lot of grief. Thank you so much !