Skip to content
Generator variables are broken for Postgres
jayhale
OP

10 hours ago

On a freshly deployed Postgres instance, the POSTGRES_PASSWORD variable is set to secret%2832%2C %22abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ%22%29.

If I try to set the value to ${{ secret(32,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') }} I end up with the same issue.

The only way to get a fresh Postgres db working is to manually set POSTGRES_PASSWORD and to alter the password for the database user.

Awaiting User Response

3 Replies

Railway
BOT

10 hours ago

Generator functions like secret() run when a template is deployed, and the result replaces the ${{ ... }} at that point, so typing that expression into a variable on a service that is already running is not something that gets evaluated afterward.

To get a working generated password on that Postgres service without editing variables by hand, open the service, go to Database > Config > Connection, and click Regenerate. That changes the password inside Postgres, updates the service variables to match, and redeploys the database, and services in the same environment that reference the password through Railway variables are redeployed automatically. Anything using a pasted connection string, or connecting from outside Railway, needs the new value entered manually.


Status changed to Awaiting User Response Railway • about 10 hours ago


jayhale
OP

5 hours ago

This seems like a bug - if I open Config in the Postgres service, and preview the password there, I see the string secret(32,'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ') on a fresh install.

I would expect to see the result of the secret generator, not the secret generator string without template tags.


Status changed to Awaiting Railway Response Railway • about 5 hours ago


Railway
BOT

5 hours ago

Thanks for the clarification. Our earlier reply covered typing the expression into a variable on a service that is already running, and that doesn't fit what you're describing. A Postgres service deployed from the template should get a generated password, not the literal secret(...) text.

We can't see variable values from our side, so we can't confirm what your service holds or why the deploy produced that. To get a working generated password without hand-editing variables, open the Postgres service, go to Database > Config > Connection, and click Regenerate. That sets a new password inside Postgres, updates the service variables to match, and redeploys the database. Services in the same environment that reference the password through Railway variables are redeployed automatically.


Status changed to Awaiting User Response Railway • about 5 hours ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...