7 hours ago
Hi,
I have a Postgres password desync issue. After manually rotating the
POSTGRES_PASSWORD variable in my Postgres service, the actual database
user password did not update, causing my web service to fail with:
"FATAL: password authentication failed for user postgres"
Symptoms:
- /api/me endpoint returns 200 (cached USERS)
- Database queries fail with 500 errors
- Both internal (postgres.railway.internal) and external
(metro.proxy.rlwy.net) connections fail
What I tried:
- Updated POSTGRES_PASSWORD, DATABASE_URL, DATABASE_PUBLIC_URL in Postgres service
- Updated DATABASE_URL in my web service
- All 4 variables now have the same password value
- Web service still fails to authenticate
Please help reset the database user password to sync with the
POSTGRES_PASSWORD variable.
Project: reformance-portal
Service: Postgres + reformance-portal (web)
2 Replies
Status changed to Open Railway • about 7 hours ago
7 hours ago
Try this:
1. Disable all public networking on the database if you have any, as the following steps will disable user authentication
2. SSH into your database service (right click your service and select Copy SSH Command)
3. 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)
4. Redeploy your database
5. SSH again, and run the command psql
6. Run ALTER USER postgres with password '<PASSWORD>'; where <PASSWORD> is the value of the variable PGPASSWORD in your Railway dashboard
7. Type exit
8. 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)
9. Redeploy your database
5 hours ago
Try to regenerate the password from your service settings, and see if that helps.
Attachments
Status changed to Awaiting User Response Railway • about 5 hours ago