fly postgres detach fails with Error: command is not compatible with this image

I am running an app on hobby plan that has a postgres database attached. There has been a hardware failure affecting the database and I am trying to restore following provided instructions here Troubleshoot apps when a host is unavailable · Fly Docs and Backup, Restores, & Snapshots · Fly Docs. I’ve created the new postgres app from a snapshot but when I do

fly postgres detach <old-db-app-name> -a <app-name>

I get this error

Error: command is not compatible with this image

I don’t know what this means. I currently have 2 database apps but the main app is connected to the non-functioning one and I don’t know how to resolve it. Any advice would be welcome!

p.s. now I have 2 database apps showin gin my dashboard, I guess this will incur charges? I didn’t want to delete anything until I know I can make the app work again (but I have data safely stored elsewhere).

Hi… Looking at the source code, this particular message comes up when it can’t resolve the image version at all. (In contrast, the wording for version mismatch is relatively verbose.)

This might be a side effect of the hardware failure.

I would try manually connecting into the new database before proceeding further…

$ fly pg connect -a <new-db-app-name>
# \l
# \c main_app_name
# \dt
# select * from some_important_table;
# select * from some_other_table;
# \q

Substitute the actual values that you see in the \l and \dt lists; the idea is just to make sure that everything really is there.

If everything looks ok, then my guess is that you can go ahead with fly pg attach. (You may get warnings about a preexisting attachment, preexisting user, …)

(And the DATABASE_URL secret may also need to be manually removed first.)

This is wise… Depending on the details, you may get charged for both databases, but it’s probably worth it in the short term.


Aside: The app itself (<old-db-app-name>) doesn’t incur charges. Try looking for any surviving Machines and/or volumes, to get an idea of how much this will cost per day…

$ fly m   list -a <old-db-app-name>
$ fly vol list -a <old-db-app-name>

If there are running machines listed, then you can save a little money via fly m stop -a <old-db-app-name>, after you’ve finished altering the attachment.

[This is assuming that your main app has two or more machines of its own.]

Hope this helps a little!

Thanks for the help. I have verified that the new data base app contains the expected data. I then removed the DATABASE_URL secret from the main app (which causes it to fail to start since it checks for this on startup, should be ok though). I then tried

fly pg attach <new-db-app-name>

and it tells me the database already exists and asks if I want to continue, selecting Y to continue I then get an error

Error: database user "<my-db-user>" already exists. Please specify a new database user via --database-user

Here I am not so sure what to do. Do I need to choose a new name and update my applications configuration files to match? Or is there some way to continue using the existing name?

Thanks again.

It doesn’t look like there’s a way to continue using the existing user name, unfortunately. (This may have changed since the documentation was written.) In most cases, your main application only knows this name via the DATABASE_URL, which fly pg attach will automatically re-create.

If your main app does fit that description, and if you weren’t doing anything fancy with roles or permissions within Postgres (which most people do not get fancy about), then you should probably be ok with --database-user new-<my-db-user>.

Sorry you’ve been having so much trouble with this!

You are correct, my application does only use DATABASE_URL, I got that confused.

I have followed your advice and now have my main app back up and running with the new database app. After I verified it was working I was able to delete the old non-functioning postgres app entirely so extra volumes and machines (potentially incurring charges) are gone and I am back to the set up I had before.

Thanks a lot for your assistance, I really appreciate it, and I’ve learned some things!

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.