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
21 Replies
Project ID:
1b609084-6c26-417b-ab8a-ba7e6d25180f
1b609084-6c26-417b-ab8a-ba7e6d25180f
try adding a 3 second sleep before your start command
how can I do this? sorry I'm very new to programming
what's your current start command/script
npm run start:prod
Solution
sleep 2 && npm run start:prod
thanks
that's 2 but close enough
solved it
thanks guys
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
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.
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.
The screenshots like so bad, sorry. But it starts trying to connect at 07:08:52 and finally connects at 07:09:53
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
How would the retry mechanism introduce delay? Caching the DNS on the first try?
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
Ok, thanks π
I'll add a sleep command
no problem, I agree this is a horrible developer experience, and this initialisation time will not always exist