R
Railway•7mo 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•7mo ago
Project ID: 1b609084-6c26-417b-ab8a-ba7e6d25180f
Next
Next•7mo ago
1b609084-6c26-417b-ab8a-ba7e6d25180f
Next
Next•7mo ago
Next
Next•7mo ago
No description
Brody
Brody•7mo ago
try adding a 3 second sleep before your start command
Next
Next•7mo ago
how can I do this? sorry I'm very new to programming
Brody
Brody•7mo ago
what's your current start command/script
Next
Next•7mo ago
npm run start:prod
Solution
Medim
Medim•7mo ago
sleep 2 && npm run start:prod
Next
Next•7mo ago
thanks
Brody
Brody•7mo ago
that's 2 but close enough
Next
Next•7mo ago
solved it thanks guys
emi0x7d1
emi0x7d1•7mo 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•7mo 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•7mo 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•7mo 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•7mo 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•7mo ago
How would the retry mechanism introduce delay? Caching the DNS on the first try?
Brody
Brody•7mo 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•7mo ago
Ok, thanks 🙂 I'll add a sleep command
Brody
Brody•7mo ago
no problem, I agree this is a horrible developer experience, and this initialisation time will not always exist