a month ago
My Postgres service password is out of sync with the actual role password.
What happened:
-
I edited POSTGRES_PASSWORD in the Postgres service variables (twice).
-
Afterwards I saw your warning: "This will manually change the password
variable without updating the actual database password."
-
Now nothing can authenticate as the postgres role.
What fails:
-
My app (Prisma): Error: P1000: Authentication failed against database
server, the provided database credentials for
postgresare not valid.Datasource: postgres.railway.internal:5432, database "railway".
-
Your own Database tab: stuck on "Attempting to connect to the database..."
-
psql from the service Console:
psql: error: connection to server at "postgres.railway.internal", port 5432
failed: FATAL: password authentication failed for user "postgres"
I tried connecting with the original password and with both values I set —
all fail. The service Console has no local socket (/var/run/postgresql is
empty), so I cannot use trust authentication to run ALTER USER.
The recommended solution (Database > Config tab) does not load, because it
needs a working database connection first. I'm on the Hobby plan, so I have
no backups available.
The volume and the data are intact. I only need the postgres role password
to be reset so it matches POSTGRES_PASSWORD again.
Project: APP-Linum
Service: Postgres (ghcr.io/railwayapp-templates/postgres-ssl:18)
2 Replies
a month ago
This thread has been opened as a bounty so the community can help solve it.
Status changed to Open Railway • 29 days 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