${{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:Jump to solution
the private network is not available during build, so that's not weird at all
14 Replies
Project ID:
d26ca2a7-2446-4472-b93c-34bfbf266f48
what is the specific error you get
during static page generation on nextjs 13. ill send a screenshot, but its not letting me copy the logs
during build?
yes
which is weird, i know
Solution
the private network is not available during build, so that's not weird at all
hmm
so just use public url then?
use the public url during build and the private during runtime
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?
I have no clue, definitely can be done one way or another, but I'm not a next dev
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
both variables will exist during build
interesting, it fails when using the private url 🤔
yes I know, the private network is not available during build