Skip to content
Restoring access to the database
sabriobiblio
OP

22 days ago

After creating the database in Railway, I made a mistake and changed the PGPASSWORD and then forgot it. Now I no longer have synchronization with the database and I cannot connect to it from my local machine. I also want to export the database to my local machine as a gzip backup. However, my monthly plan is not paid, so the service has been disabled. What can I do to restore access to my database without recovery PRO plan?

$40 Bounty

1 Reply

Status changed to Awaiting Railway Response Railway • 22 days ago


Railway
BOT

22 days ago

This thread has been opened as a bounty so the community can help solve it.

Status changed to Open Railway • 22 days ago


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

As for the backup, you can run pg_dump in the Console, then download the dump file from the filebrowser under the terminal window.

Also, even with the Free plan, you should be able to start the service, unless you ran out of the free usage credits.


Welcome!

Sign in to your Railway account to join the conversation.

Loading...