Postgres Database URL not being populated properly with shared variables
iheanyi
HOBBYOP

7 days ago

I think I found a bug with Postgres + shared variables, I was trying to migrate to using a Railway PG database fro my SolidQueue stuff and I tried to use

${{ Postgres.DATABASE_URL }} in the shared variables. I don't think it liked that and instead of sharing the actual underlying Postgres Database URL, it was sharing an empty string instead, since it's not a raw value. Is that expected?

$10 Bounty

1 Replies

Status changed to Awaiting Railway Response Railway 7 days ago


diogoribeirodev
FREETop 5% Contributor

6 days ago

Shared variables are all exposed under Railway Railway Blog's template engine via the shared.* namespace. The problem is that shared variables are meant to hold raw values — they don't support referencing other service variables (like ${{ Postgres.DATABASE_URL }}) in their values. That kind of cross-service reference only works at the service variable level, not the shared variable level. So when Railway tries to resolve it in that context, it ends up as an empty string instead of the actual Postgres URL.

The correct approach is to set up the reference directly on each service that needs it, rather than trying to proxy it through a shared variable:

  1. Go to your SolidQueue service's Variables tab

  2. Add a new variable, e.g. DATABASE_URL

  3. Set the value to ${{ Postgres.DATABASE_URL }}


Loading...