Can another app connect to the DB in my railway instance?
Hi team! now that i have a postgres instance running in prod for my railway app, is it possible for another app (perhaps a next.js app) to connect to the DB using the DB URL? the best practice way should definitely be exposing an endpoint from my railway app, but im trying to hack a quick solution. thanks!
6 Replies
Project ID:
N/A
In your DB's variables you'll find a variable called
DATABASE_URL
this is the publicly exposed endpoint where you can connect to your db from anywhere
although this will cause egress usage, best practice is to use DATABASE_PRIVATE_URL
, which allows your apps to connect to your db over the private network, it only works for apps that's inside of the same project as your database thoughawesome, thanks! that's what i was thinking. i wasn't sure if that's possible when i saw the "We are unable to connect to the database over the public network." message π
Interesting, are you sure your psotgres is deployed?
you can see if it is by going to the
Deployments
tab and seeing if there's an active deploymentyes it's active
i'll try connecting it from my another app and will report back if it doesnt work
thanks for the help
Sounds good, and no problem π