Railway having trouble connecting to local db upon deployment
Hi. I recently deployed my node.js app on Railway and found out that during startup of my node.js app, railway was unable to connect/find the local db instance. It eventually was able to connect to it, after a few retries. Is the problem on my side?
Not once does the local db instance restart during deployment of the app.
Solution:Jump to solution
in that case add a
ENABLE_ALPINE_PRIVATE_NETWORKING
service variable set to true
10 Replies
Project ID:
63ba6dbb-f4be-49b5-9c9f-bd5e83221ed9
63ba6dbb-f4be-49b5-9c9f-bd5e83221ed9
Could you try adding a 3 second sleep in your start command?
Now I only get the connection error once and on the second startup it successfully connects and I bet I get no error if I sleep like 6 seconds or so because first time I had two of these.
interesting, are you deploying an alpine based image?
yes
Solution
in that case add a
ENABLE_ALPINE_PRIVATE_NETWORKING
service variable set to true
if you're curious about why this is necassery:
https://docs.railway.app/guides/private-networking#workaround-for-alpine-based-images
aha nice, now it successfully connects, thanks.
Awesome, no problem