a year ago
Building a Next.js app with IS_BUILD=true pnpm db:migrate && pnpm build gives me this error in the deployment: #13 3.900 [22:36:03] ERROR: Error: cannot connect to Postgres. Details: getaddrinfo ENOTFOUND postgres.railway.internal
Is this some Railway quirk? Looked around and couldn't find a fix for it. I'm connecting from the same region on staging.
20 Replies
a year ago
project ID: e8eef74a-59dc-42cf-9b57-69bcb2f3f816
a year ago
hello, the private network is not available during build, you would want to run your migrations during runtime before starting the app
a year ago
hmm wouldn't that result in downtime for the app? if you run the migrations and then have to wait for the deployment to finish before your frontend references the new db schema?
a year ago
it won't as long as you use a healthcheck
a year ago
damn, seems like a lot of hassle to implement a healthcheck
a year ago
means on each migration, you'd have to modify the healthcheck endpoint to verify the new schema?
a year ago
no, just return 200 after pinging your database
a year ago
alright I added an endpoint that returns 200 after connecting to the db, set the healthcheck path on Railway to /api/health, but it still fails with the same unable to connect to internal db error 😦
a year ago
@Brody
a year ago
have you stopped running migrations during build?
a year ago
ah I think that fixes it, so is the workflow on Railway to run the migrations in Github Acitons on CI, and then check the "wait for CI" option on Railway service?
a year ago
seems kind of dangerous if the build fails but migration succeeds
a year ago
or if you run it locally, there would be downtime
a year ago
trying to see if it's possible to have the deploy fail if the migration fails
a year ago
right so as previously suggested, you run your migrations during runtime before starting your app, then use a healthcheck, this way if the migration fails the app never gets deployed
a year ago
ok ok gotcha, I'll do the migrations in the start script then
a year ago
thanks!
a year ago
let me know if you have any troubles
a year ago
have things worked out for you?
a year ago
!s
Status changed to Solved brody • about 1 year ago