Password error for our build
bradhoop-777
PROOP

22 days ago

We have a Railway Postgres service with live data intact, but the Postgres user password and Railway environment variables are out of sync after a failed manual credential rotation attempt.

Postgres starts successfully and logs show:

database system is ready to accept connections

But app connections fail with:

FATAL: password authentication failed for user "postgres"

The Railway Database tab stays stuck on:

Attempting to connect to the database...

The Console/WebSocket also fails, so we cannot run ALTER USER manually.

We need Railway to safely resynchronise or regenerate the Postgres credentials without deleting the database, deleting the volume, or restoring over current data.

Project: RedPoint Social Hub

Postgres service: Postgres

Please help reset/sync:

DATABASE_URL

DATABASE_PUBLIC_URL

PGPASSWORD

POSTGRES_PASSWORD

with the actual postgres user password.

Solved$20 Bounty

Pinned Solution

Try this then:

  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

12 Replies

Railway
BOT

22 days ago

Your Postgres service's Credentials tab (open the Postgres service, go to the Database view, then Credentials) lets you safely regenerate the password while keeping the environment variables in sync, which is exactly the fix for a manual rotation that went out of sync. After regenerating, redeploy any service that references the password variables.


Status changed to Awaiting User Response Railway 22 days ago


Railway

Your Postgres service's [Credentials tab](https://docs.railway.com/databases/database-view#credentials-tab) (open the Postgres service, go to the Database view, then Credentials) lets you safely regenerate the password while keeping the environment variables in sync, which is exactly the fix for a manual rotation that went out of sync. After regenerating, redeploy any service that references the password variables.

bradhoop-777
PROOP

22 days ago

my Postgres Database connection keeps having wheel of death and not connecting so I can not regerate password


Status changed to Awaiting Railway Response Railway 22 days ago


Railway
BOT

22 days ago

This thread has been opened as a public bounty so the community can help solve it. The thread and any further activity are now visible to everyone.

Status changed to Open Railway 22 days ago


You're not able to access the console tab of your database?

Is it online?


bradhoop-777
PROOP

22 days ago

yes shows online but the database connection just spins


Are you able to access the console tab when you click on your service?


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. SSH 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

If the console tab isn't accessible, you can try setting your start command to sleep infinity, and then follow the steps 0x5b62656e5d provided.


bradhoop-777
PROOP

20 days ago

I Still Need Help


bradhoop-777
PROOP

20 days ago

Thanks. The Credentials tab is not visible for me.

Current situation:

  • Postgres service is online.
  • Postgres logs show: database system is ready to accept connections.
  • The app logs show: FATAL: password authentication failed for user "postgres".
  • The Database tab just spins at “Attempting to connect to the database…”.
  • The Console tab fails with WebSocket connection failed.
  • I cannot access psql through the Railway UI.
  • I do not want to delete the database, delete the volume, or restore over current data.

Please either:

  1. Regenerate/resynchronise the Postgres credentials from Railway’s side, or
  2. Provide exact step-by-step instructions for this specific UI/service to access the Credentials tab, or
  3. Confirm the safe recovery procedure using the pg_hba.conf trust method, including how to proceed when the Console tab is inaccessible.

Project: RedPoint Social Hub

Service: Postgres

Please confirm the safest non-destructive recovery path.


Try setting your start command to sleep infinity then see if you're able to access the console from the dashboard.


bradhoop-777
PROOP

19 days ago

I followed the suggested workaround.

I set the Postgres Custom Start Command to:

sleep infinity

Then I redeployed the Postgres service.

However, the Console still fails with:

WebSocket connection failed

Connection lost

Disconnected

I cannot access a shell to run the pg_hba.conf command.

I have reverted the Postgres Custom Start Command back to blank/default and redeployed the database so it is running normally again.

Please provide the next recovery step, or reset/resynchronise the Postgres credentials from Railway’s side.

We need to fix:

FATAL: password authentication failed for user "postgres"

without deleting the database, deleting the volume, or restoring over current data.


Try this then:

  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

Status changed to Solved 0x5b62656e5d 17 days ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...