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:
- Attempted to connect locally using the
DATABASE_PUBLIC_URL: - Connection fails with:
FATAL: password authentication failed for user "postgres" - Verified the password is correctly set in the Variables tab
- Restarted the Postgres deployment
- 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
Pinned Solution
23 days ago
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
23 days ago
Try regenerating the password, then copy the public URL to connect to your db.
Attachments
23 days ago
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.
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