R
Railwayβ€’13mo ago
Next

Prisma not reach database

Hi, I'm trying to deploy my Nest application with Prisma but it was crashing all the time and on deploy log the error on image below appears. I'm trying to connect using MYSQL_PRIVATE_URL
No description
Solution:
sleep 2 && npm run start:prod
Jump to solution
21 Replies
Percy
Percyβ€’13mo ago
Project ID: 1b609084-6c26-417b-ab8a-ba7e6d25180f
Next
NextOPβ€’13mo ago
1b609084-6c26-417b-ab8a-ba7e6d25180f
Next
NextOPβ€’13mo ago
Next
NextOPβ€’13mo ago
No description
Brody
Brodyβ€’13mo ago
try adding a 3 second sleep before your start command
Next
NextOPβ€’13mo ago
how can I do this? sorry I'm very new to programming
Brody
Brodyβ€’13mo ago
what's your current start command/script
Next
NextOPβ€’13mo ago
npm run start:prod
Solution
Medim
Medimβ€’13mo ago
sleep 2 && npm run start:prod
Next
NextOPβ€’13mo ago
thanks
Brody
Brodyβ€’13mo ago
that's 2 but close enough
Next
NextOPβ€’13mo ago
solved it thanks guys
emi0x7d1
emi0x7d1β€’13mo ago
I have the same problem but I just increased the connection timeout. Any idea why this happens? A job that hasn't finished? In my case, I have to wait almost a minute for it to connect after multiple retries
Brody
Brodyβ€’13mo ago
the internal dns resolver takes ~2 seconds to start, aka for the first ~2 seconds of your app start you can't resolve the internal domain names, increasing the connection timeout or adding a sleep command achieve the exact same thing. railway is actively working to eliminate this delay in the private networking.
emi0x7d1
emi0x7d1β€’13mo ago
In my case, I'm seeing way more than a 2 second delay. The DB was already running way before that and I could connect to it externally.
No description
No description
emi0x7d1
emi0x7d1β€’13mo ago
The screenshots like so bad, sorry. But it starts trying to connect at 07:08:52 and finally connects at 07:09:53
Brody
Brodyβ€’13mo ago
it's takes 2 seconds on average for the dns resolver to start answering requests, I have tested this many thousands of times I think the longest I've ever seen it take was 3.7 seconds any additional delay would be introduced by the retry mechanism built into the library
emi0x7d1
emi0x7d1β€’13mo ago
How would the retry mechanism introduce delay? Caching the DNS on the first try?
Brody
Brodyβ€’13mo ago
dns timeouts, dial timeouts, etc, all can extend the time it takes to connect when there is an initial failure, sleep for 2 or 3 seconds and then you will be able to connect first try without any issues
emi0x7d1
emi0x7d1β€’13mo ago
Ok, thanks πŸ™‚ I'll add a sleep command
Brody
Brodyβ€’13mo ago
no problem, I agree this is a horrible developer experience, and this initialisation time will not always exist
Want results from more Discord servers?
Add your server