a month ago
Project ID: c4778036-48e2-4b03-be21-419ec6a0403d
Service ID: 280c6978-5a84-4c7b-8bd0-f9a89c881770
Issue: New connections to my Postgres service fail with "password authentication failed for user postgres" when using the exact POSTGRES_PASSWORD value shown in the Variables tab. My app's existing long-lived connection (established before this issue started) continues to work fine without re-authenticating.
Timeline: This started around 12:12 UTC on 2026-07-22. It was preceded by an earlier incident where my "railway" database was found completely empty (only default postgres/template0/template1 databases remained), which I had to recreate manually.
What I believe happened: The POSTGRES_PASSWORD variable was regenerated/reset at some point, but the password hash stored on the persistent volume's data directory was not updated to match, so Postgres is still authenticating against the old hash.
Request: Please update the password hash on the volume's Postgres data directory to match the current POSTGRES_PASSWORD variable value, or let me know the correct current password if it differs from what's shown in the dashboard.
I have NOT restarted the Postgres service or my app since discovering this, to avoid losing the one working connection. Please advise before I take any action.
1 Replies
a month ago
This thread has been opened as a bounty so the community can help solve it.
Status changed to Open Railway • about 1 month ago
a month ago
Try this:
- Click into your database service and go to the console tab
- Run this command:
sed -i 's/host all all all scram-sha-256/host all all ::\/0 trust/' /var/lib/postgresql/data/pgdata/pg_hba.conf(This will bypass user authentication) - Redeploy your database
- Console again, and run the command
psql - Run
ALTER USER postgres with password '<PASSWORD>';where<PASSWORD>is the value of the variablePGPASSWORDin your Railway dashboard - Type
exit - Run
sed -i 's/host all all ::\/0 trust/host all all all scram-sha-256/' /var/lib/postgresql/data/pgdata/pg_hba.conf(This will re-enable user authentication) - Redeploy your database