R
Railway•6mo ago
Jin

Databases not connecting after a failed payment

I have some services running on Railway for a long time but I missed the payment. I paid and restarted all services but the databases were not connecting, I have 3 of them. Kindly help
Solution:
tl;dr: add a 3 second sleep to the beginning of your start command and connect to the database over the private network
Jump to solution
76 Replies
Percy
Percy•6mo ago
Project ID: N/A
Jin
JinOP•6mo ago
NA @Brody kindly check this out
Brody
Brody•6mo ago
#🛂|readme #5
Jin
JinOP•6mo ago
what do you need ?
Brody
Brody•6mo ago
please read it
Jin
JinOP•6mo ago
I have I am not sure what to look for
Brody
Brody•6mo ago
#5 read readme #5 ping
Jin
JinOP•6mo ago
Okay, as i said earlier I have been trying to fix the db connection issue on my railway for about 6 hours now. They are 3 different services and they are in production. this affects our business.
Brody
Brody•6mo ago
are you on pro?
Jin
JinOP•6mo ago
just checked, it's hobby
Brody
Brody•6mo ago
you should not be running a business on a hobby plan meant only for hobby projects, please upgrade to pro at your earliest convenience
Jin
JinOP•6mo ago
understood can you see my actual problem in the first message of the thread ?
Brody
Brody•6mo ago
what is the state of your database deployment please tell me the state of the deployment
Jin
JinOP•6mo ago
Active
Brody
Brody•6mo ago
send the deploy logs for postgres please - https://bookmarklets.up.railway.app/log-downloader/
Jin
JinOP•6mo ago
do i upload here ?
Brody
Brody•6mo ago
yes thanks, show me a screenshot of the public networking try re-deploying the database
Jin
JinOP•6mo ago
thanks
Brody
Brody•6mo ago
can you connect to it
Jin
JinOP•6mo ago
after showing this for a while, it sometimes open up the data then it disconnects again
Brody
Brody•6mo ago
please use a proper database client like dbgate
Jin
JinOP•6mo ago
it works before now, However, my interest is not seeing the db, but to make the connection work on the backend we are using. The connection issue breaks the backend
Brody
Brody•6mo ago
are you able to connect to the database with dbgate?
Jin
JinOP•6mo ago
i have been able to connect using dbgate
Brody
Brody•6mo ago
have your application connect to the database via the private network
Jin
JinOP•6mo ago
ok the application log prints the same issue and it's now crashed can't reach database server @ ....
Brody
Brody•6mo ago
please include the full error message what is your current start script
Jin
JinOP•6mo ago
start is default The database itself fails to connect, so i don't think it is an issue from the application
Brody
Brody•6mo ago
I don't know what "start is default" means, please tell me what you have for your start script
Jin
JinOP•6mo ago
i am not sure of that but we didnt put anything if it's the start command
Brody
Brody•6mo ago
please tell me what you have for your start script, if you are unfamiliar with node development, this can be found in your package.json
Jin
JinOP•6mo ago
nest start
Brody
Brody•6mo ago
try changing that to sleep 3 && nest start
Jin
JinOP•6mo ago
doesn't work.
Brody
Brody•6mo ago
please show me your scripts
Jin
JinOP•6mo ago
okay, i will check but just to be clear, 1. if i make a new environment of the databse and enter it to the application, it will work. 2. The app deploys and start properly, there is. no start problem as we have been using it until I noticed subscription ended today
Jin
JinOP•6mo ago
No description
Brody
Brody•6mo ago
please try my suggested fix
Jin
JinOP•6mo ago
it doesn't work
Brody
Brody•6mo ago
im not seeing my suggested fix here?
Jin
JinOP•6mo ago
i entered it directly on railway
Brody
Brody•6mo ago
please show me how you have implemented it
Jin
JinOP•6mo ago
i edited this now, I am waiting for the build I edited the "start" to with the value you sent
Jin
JinOP•6mo ago
No description
Brody
Brody•6mo ago
i had previously asked you to have your app connect to the database via the private network, please do that now
Jin
JinOP•6mo ago
yes, i used it and it crashed, I just tried it now, same thing
Brody
Brody•6mo ago
please always show the error
Jin
JinOP•6mo ago
it's the same thing, no differnce
Brody
Brody•6mo ago
every little bit of info helps im only trying to help you
Brody
Brody•6mo ago
thank you is the database in the same project?
Jin
JinOP•6mo ago
what does in the same project mean ?
Brody
Brody•6mo ago
same railway project
Jin
JinOP•6mo ago
no
Brody
Brody•6mo ago
please show a screenshot of your railway project
Jin
JinOP•6mo ago
i just tried creating a db in the project now, i deleted it after that. I have 4 different services running. 1 worked well after making the payment but the remaining have issues with db connection
Brody
Brody•6mo ago
your database needs to be in the same project to use the private network
Jin
JinOP•6mo ago
got it, what's to be done ?
Brody
Brody•6mo ago
move your bot service into the same project as the database
Jin
JinOP•6mo ago
i don't see how to move it
Brody
Brody•6mo ago
its a manual process
Jin
JinOP•6mo ago
i create a new database ?
Brody
Brody•6mo ago
i did not say that
Jin
JinOP•6mo ago
manual is not clear
Brody
Brody•6mo ago
you need to deploy your bot service into the same project as the database
Jin
JinOP•6mo ago
ok this trick works. Thanks!
Brody
Brody•6mo ago
no problem you do need to keep the sleep 3 please dont remove that or you will face issues again
Jin
JinOP•6mo ago
okay. Why does it need the sleep 3
Brody
Brody•6mo ago
the private network is not available for the first 3 seconds
Jin
JinOP•6mo ago
okay but what's wrong with the public network
Brody
Brody•6mo ago
nothing, you had something missconfigured, so its better to use the private network as that wont result in database <--> service egress fees
Jin
JinOP•6mo ago
okay, but the database doesn't connect as well, so could that be from me ?
Brody
Brody•6mo ago
this would be due to a misconfiguration on your side, unfortunately i was not able to find out what that is, but either way, using the private network is much preferred
Jin
JinOP•6mo ago
okay, thanks
Brody
Brody•6mo ago
no problem!
Solution
Brody
Brody•6mo ago
tl;dr: add a 3 second sleep to the beginning of your start command and connect to the database over the private network
Want results from more Discord servers?
Add your server