R
Railwayβ€’4mo ago
Anubhav

Connect database locally

is it possible to connect with local_db_url which is of postgres by local_db_url i mean the one of railway service
Solution:
Hey there, little correction needed - For Postgres databases that are recently deployed you can simply reference DATABASE_URL as it is now the private url...
Jump to solution
14 Replies
Percy
Percyβ€’4mo ago
Project ID: N/A
Anubhav
AnubhavOPβ€’4mo ago
N/A
𝐗-π₯𝐞𝐦
You want to connect to a psql DB from your local computer? If so then yes, you just need to use the public url
Anubhav
AnubhavOPβ€’4mo ago
if same project have two service one db and one py app both can communicate locally ?
Anubhav
AnubhavOPβ€’4mo ago
this is the structure
No description
Anubhav
AnubhavOPβ€’4mo ago
AFW-bot wants to talk with postgres
𝐗-π₯𝐞𝐦
The AFW-bot can connect to the postgres instance. You should use the private DB url for that though. You can add a env variable to AFW-bot (will be something like ${{Postgres.DATABASE_PRIVATE_URL}}). Then just grab that env variable in your python application to connect to the DB.
Anubhav
AnubhavOPβ€’4mo ago
ok so private db wont cost me right? only the public one costs? url i mean
Solution
Brody
Brodyβ€’4mo ago
Hey there, little correction needed - For Postgres databases that are recently deployed you can simply reference DATABASE_URL as it is now the private url
𝐗-π₯𝐞𝐦
They'll both count towards your usage. It's just better to use a private URL within your service. See: https://railway.app/changelog/2024-07-19-database-private-networking#database-private-network-defaults
Anubhav
AnubhavOPβ€’4mo ago
oki
Brody
Brodyβ€’4mo ago
Hey, correction again, database to service communication over the private network does not cost anything on egress
𝐗-π₯𝐞𝐦
But they still have resource usage eh? They're not free
Brody
Brodyβ€’4mo ago
yes of course, but there will be no egress
Want results from more Discord servers?
Add your server