Postgres role password out of sync — cannot authenticate, Config tab won't load
haguilar1001
HOBBYOP

a month ago

My Postgres service password is out of sync with the actual role password.

What happened:

  1. I edited POSTGRES_PASSWORD in the Postgres service variables (twice).

  2. Afterwards I saw your warning: "This will manually change the password

    variable without updating the actual database password."

  3. 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 postgres are 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)

$10 Bounty

2 Replies

Railway
BOT

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



Try this:

  1. Click into your database service and go to the console tab
  2. 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)
  3. Redeploy your database
  4. Console again, and run the command psql
  5. Run ALTER USER postgres with password '<PASSWORD>'; where <PASSWORD> is the value of the variable PGPASSWORD in your Railway dashboard
  6. Type exit
  7. 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)
  8. Redeploy your database

Welcome!

Sign in to your Railway account to join the conversation.

Loading...