NestJS API Struggling to Connect to PostgreSQL

Every time I deploy my app, I repeatedly get an error that my Nest API can't connect to the Postgres database (I'm connecting them over the private network but have tried the public URL as well). Normally after 5-10 tries it's able to connect, but occasionally it times out and the deployment crashes. My service is also completely unavailable for the 2-3 minutes its trying to connect. I have a nearly identical setup on Heroku and it works fine so I don't think its anything with my Nest setup. Project ID: 9e146e97-31c4-4151-baef-6ebb85aa849d
No description
10 Replies
Percy
Percy12mo ago
Project ID: 9e146e97-31c4-4151-baef-6ebb85aa849d
Brody
Brody12mo ago
can you try to add a 3 second sleep to your start script?
gregfromstl
gregfromstlOP12mo ago
No difference 🙁
Brody
Brody12mo ago
show me how youe done that?
gregfromstl
gregfromstlOP12mo ago
No description
Brody
Brody12mo ago
to eliminate variables, please do the sleep in your start script (in package.json) sleep 3 && <your current start command>
gregfromstl
gregfromstlOP12mo ago
Okay I figured it out. I was running npx prisma migrate deploy before the start command. What is the recommended way to check for new database migrations when deploying?
Brody
Brody12mo ago
in the start command the sleep 3 should solve it
gregfromstl
gregfromstlOP12mo ago
when I had npx prisma migrate deploy && sleep 3 && yarn start it was still happening Should sleep come before the migrations?
Brody
Brody12mo ago
sleep should be at the start
Want results from more Discord servers?
Add your server