DATABASE_URL reference resolving to wrong password - auth failing
vladagureev
PROOP

a month ago

Hi, I'm having an issue where my app service (Outclas) cannot connect to my Postgres service (Postgres-Evpm). The DATABASE_URL reference variable in my app resolves to a connection string with a different password than what POSTGRES_PASSWORD shows in the Postgres service variables. This causes a password authentication failed for user "postgres" error on every deployment. I've tried manually hardcoding the connection string but the password seems inconsistent across variables. Can you help me figure out what the actual correct password is and why the reference isn't resolving correctly?

Solved$10 Bounty

Pinned Solution

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

2 Replies

Railway
BOT

a month ago

This typically happens when the POSTGRES_PASSWORD variable was manually edited after the database was first created, since Postgres only uses that variable to set the password on initial startup. The variable value changed but the actual database password did not. To fix this, use the Credentials tab in your Postgres service's Data panel, which safely regenerates the password and keeps the database and environment variables in sync, then redeploy any dependent services like Outclas.


Status changed to Awaiting User Response Railway about 1 month ago


Status changed to Awaiting Railway Response Railway about 1 month ago


Railway
BOT

a month ago

This thread has been marked as public for community involvement, as it does not contain any sensitive or personal information. Any further activity in this thread will be visible to everyone.

Status changed to Open Railway about 1 month 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


Status changed to Solved vladagureev about 1 month ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...