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:Jump to 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...14 Replies
Project ID:
N/A
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
if same project have two service one db and one py app both can communicate locally ?
this is the structure
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.ok so private db wont cost me right? only the public one costs?
url i mean
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 urlThey'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
oki
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
yes of course, but there will be no egress