Unable to swap volumes in a Postgres service

3 months ago

Hi, I get this error when trying to swap the volumes:

Service already has a volume attached in this environment (VolumeInstance d437b901-f365-462d-bb1c-ff1b256c192d, Volume d9c855a8-f918-4d73-a15a-90f2b84b09f6). A service can only have one volume.

(We fucked up a migration xd)

Solved

21 Replies

3 months ago

Viewing the IDs, we need to swap the volume d9c855a8-f918-4d73-a15a-90f2b84b09f6 for the a75b751e-adbf-47bc-bc54-c6a0b9e70998. The volume with the ID d437b901-f365-462d-bb1c-ff1b256c192d actually doesn't exist?


3 months ago

This also is preventing backups from being restored


3 months ago

I tried to create a new postgres service, then set the volume it to and then change the connection string, but it stills fails to do the swap in new postgres services


Did you unmount volumes associated with both services first?


3 months ago

I could not find a button to do it


Nevermind. You need to delete the service to unmount the volume, as the service requires a volume.


3 months ago

I think I fixed btw


3 months ago

Creating a new postgres service and drag and dropping the volume to it seems to work


3 months ago

But using the button doesn't

image.png

Attachments


3 months ago

nvm, did't work


(You might get password errors)


Which part didn't work?


3 months ago

image.png

Attachments


3 months ago

you were right btw


3 months ago

image.png

Attachments


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 ''; where `` 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

3 months ago

That work and now the new service actually works


3 months ago

Now it should be just changing the env vars


3 months ago

Well, everything is now working. Thank you very much and God bless :3


3 months ago

I will not delete the original database and volume if some railway admin wants to check them later, may find the root of the issue


np


Status changed to Solved 0x5b62656e5d 3 months ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...