R
Railwayβ€’10mo ago
gary

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
Percy
Percyβ€’10mo ago
Project ID: N/A
Fragly
Fraglyβ€’10mo ago
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 though
gary
garyOPβ€’10mo ago
awesome, 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 πŸ˜…
No description
Fragly
Fraglyβ€’10mo ago
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 deployment
gary
garyOPβ€’10mo ago
yes it's active i'll try connecting it from my another app and will report back if it doesnt work thanks for the help
Fragly
Fraglyβ€’10mo ago
Sounds good, and no problem πŸ™‚
Want results from more Discord servers?
Add your server