Unstable connection to MongoDB via private network
Hi everyone,
Just today my app receives some errors in MongoDB connection, below is the log files (I've attached the screenshot, too):
It seems that the URL that should have been set for private networking @
mongodb.railway.internal
could not be recognized by my container running in the same project.
This problem seems to happen intermittently though.
Because my services are live already, I had to switch the MongoDB URL to the public one instead (which would cost me egress network costs).
Please let me know if this is a known issue, or if there is anything else that I should do from my side.
As a dev, aside from reasons based on the costs, I would also prefer the usage of private network to access the DB.
In summary: the private URL access for MongoDB seems to be unstable currently, sometimes the request went thru, sometimes it would just result in a timeout.
Thanks a lot!Solution:Jump to solution
yes please add a 3 second sleep to the start command so the starting of your app is delayed
20 Replies
Project ID:
a764e147-c28b-4388-85d2-547de92d2fd0
a764e147-c28b-4388-85d2-547de92d2fd0
dockerfile or nixpacks based build?
It's nixpacks-based build.
node.js based app, but I didn't build the image myself. I let nixpacks build it.
do you have a 3 second sleep in your start script?
No, I don't have that. Should I add it manually?
Solution
yes please add a 3 second sleep to the start command so the starting of your app is delayed
ah ok I will add it
just a question though: is the 3s sleep relevant to the problem? in my screenshot above, the problem seems to only occur pretty much recently.
the deployed image was running properly for days and it never had problem accessing the MongoDB via internal network
yes the private network is not available for the first 3 or so seconds
I see... Gotcha I will try it
Also, I browsed around and it looks like I'd need to add this as well in environment variable:
ENABLE_ALPINE_PRIVATE_NETWORKING=true
Do I need it to add this option, too?
you said you where using nixpacks right? nixpacks is not based on alpine
I see, nevermind then. Yes it's from nixpacks.
ok this seems to do the trick. my error is gone now.
awsome
I even spammed the services and it seems to work fine. access to MongoDB via internal network seems to be stable.
happy to hear it
Hey, it seems i have the same issue, the first 3 seconds of deploy process don't have access to exposed private network ?
I have another question, is the private network exposed on all projets of the organization, or is it only accessible through the project?
everyone has the same issue, there is about a 3 second delay for every service deployed to railway before the private network is fully available.
the private networks are scoped to a single environment, meaning each environment within a project is its own private network, and services can only talk to other services in the same environment within the same project.
ok nice, thanks for the explanations π
furthermore, this will be fixed in due time, when fixed there will be zero delay to the availability of the private network when deployments start
Thanks for being helpful as always @Brody!