PostgreSQL password authentication mismatch on fresh services
yasemincalikusu26-commits
HOBBYOP

a month ago

Hello Railway Support,

I am experiencing a reproducible PostgreSQL authentication issue in my Railway project.

Project: eloquent-encouragement

Environment: production

I created two separate fresh PostgreSQL services:

  • Postgres-5THB
  • Postgres-L--w

Both services performed a full clean initdb initialization with fresh volumes and completed successfully.

However, external connections from my n8n service fail with:

FATAL: password authentication failed for user "postgres"

The n8n service uses Railway service-reference variables from the corresponding PostgreSQL service:

PGHOST

PGPORT

PGDATABASE

PGUSER

PGPASSWORD

This happened independently with both newly initialized PostgreSQL services.

The PostgreSQL servers themselves are online, user postgres exists, and remote authentication is configured with scram-sha-256.

It appears that the Railway-generated POSTGRES_PASSWORD / PGPASSWORD value exposed to other services does not match the password hash initialized for the postgres database user.

Could you please investigate whether PostgreSQL template credential generation / propagation is functioning correctly for this project?

Please do not delete, recreate, or modify my existing services without my confirmation.

My existing bridge service and Amazon SP-API credentials must remain untouched.

$10 Bounty

3 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 • about 1 month ago


Are you able to do a credential rotation by going into the Postgres service > Database > Config?


You need to redeploy the n8n service for the reference variables to be updated.


larrybol
PRO

an hour ago

On fresh Railway Postgres services this is almost always stale variable references, not a wrong password.

  1. In the connecting service, delete PGHOST, PGPORT, PGUSER and PGPASSWORD entirely, then re-add them via "Add Variable Reference" pointing at the Postgres service. Never paste the values by hand.
  2. If you regenerated the Postgres password at any point, the references don't update on their own — delete and re-add them after the regen.
  3. Check which endpoint the app is actually hitting: services inside the same Railway project must use the private/internal hostname, not the public TCP proxy URL. Mixing them up produces exactly this FATAL error.
  4. Sanity-check the password itself from your machine: psql with the public connection URL. If that connects, the credential is fine and the problem is the app's config.
  5. Make sure you don't have two Postgres services in the project — a deleted one leaves dangling variable references that look identical.

Welcome!

Sign in to your Railway account to join the conversation.

Loading...