R
Railway•11mo ago
Dylpickle

${{Postgres.PRIVATE_DATABASE_URL}} connection fails, but ${{Postgres.DATABASE_URL}} works

${{Postgres.PRIVATE_DATABASE_URL}} connection fails, but ${{Postgres.DATABASE_URL}} works project id d26ca2a7-2446-4472-b93c-34bfbf266f48
Solution:
the private network is not available during build, so that's not weird at all
Jump to solution
14 Replies
Percy
Percy•11mo ago
Project ID: d26ca2a7-2446-4472-b93c-34bfbf266f48
Brody
Brody•11mo ago
what is the specific error you get
Dylpickle
Dylpickle•11mo ago
during static page generation on nextjs 13. ill send a screenshot, but its not letting me copy the logs
Brody
Brody•11mo ago
during build?
Dylpickle
Dylpickle•11mo ago
yes which is weird, i know
Solution
Brody
Brody•11mo ago
the private network is not available during build, so that's not weird at all
Dylpickle
Dylpickle•11mo ago
hmm so just use public url then?
Brody
Brody•11mo ago
use the public url during build and the private during runtime
Dylpickle
Dylpickle•11mo ago
not exactly sure how to do that? that does't make alot of sense to me, if you could explain. if you build using a public url, your deployed package has that env var baked in, does it not?
Brody
Brody•11mo ago
I have no clue, definitely can be done one way or another, but I'm not a next dev
Dylpickle
Dylpickle•11mo ago
no worries, ill try to figure it out - thanks for the quick response! i have an idea actually for anyone who reads this thread when creating a connection to the db just put an or operator process.env.DATABASE_PRIVATE_URL || process.env.DATABASE_URL it will build using the private url if it has it, then move to the public if it doesnt
Brody
Brody•11mo ago
both variables will exist during build
Dylpickle
Dylpickle•11mo ago
interesting, it fails when using the private url 🤔
Brody
Brody•11mo ago
yes I know, the private network is not available during build
Want results from more Discord servers?
Add your server