Postgres connexion error
gandalfthewhite777
HOBBYOP

23 days ago

I have a Postgres database with a password mismatch. I can't connect to back it up, but I don't want to delete the volume without backing up first. I need help recovering the data or safely deleting the volume.

Issue Summary:

I deployed a Postgres database on Railway and set the password via the POSTGRES_PASSWORD environment variable.

What I've tried:

  1. Attempted to connect locally using the DATABASE_PUBLIC_URL:
  2. Connection fails with: FATAL: password authentication failed for user "postgres"
  3. Verified the password is correctly set in the Variables tab
  4. Restarted the Postgres deployment
  5. Redeployed Postgres entirely

Root cause identified: The Postgres container has a persistent volume with old password hash data. When Postgres starts, it uses the old password hash from the volume instead of the new POSTGRES_PASSWORD environment variable. This creates a mismatch.

Current situation:

  • Cannot connect to the database to back it up (chicken-and-egg problem)
  • Don't want to delete the volume without backing up first
  • Need help either: (a) recovering/backing up the data, or (b) safely deleting the volume so I can start fresh
Solved$10 Bounty

Pinned Solution

Try regenerating the password, then copy the public URL to connect to your db.

Attachments

4 Replies

Status changed to Open Railway 23 days ago


Try regenerating the password, then copy the public URL to connect to your db.

Attachments


You can also get a pg_dump backup file using your private network. Use postgres-backup-api template to achieve this. You simply add it to your project, set your DATABASE_URL variable, then navigate to its http URL, and it will download a backup file on your machine.


23 days ago

If it is as you said: "The data is hashed with the old password" then I'm afraid there's not much you can do unless you recover the old password.


gandalfthewhite777
HOBBYOP

23 days ago

Thanks a lot for your replies everyone. I had tried to reset my password 2-3 times and for some reason, when I retried again it worked.... go figure ...

Anyway, thanks a lot again for your help,


Status changed to Solved medim 23 days ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...