Rails App deployment error: Failed due to unhealthy allocation

Hi there - I’m new to Fly and I have been trying to deploy a rails app (was previously using Heroku’s free plan).

I get “failed due to unhealthy allocation - not rolling back to stable job version 5 as current job has same specification and deploying as v6” at the tail end of the deployment process. When I run fly logs (see screenshot below), I get this error:

Preparing to run: /rails/bin/docker-entrypoint ./bin/rails server as rails
2023-03-22T08:55:10Z app[c4be202b]
[ r: UnhandledIoError(Os { code: 2, kind: NotFound, message: “No such file or directory” })

Could someone please help?

Quick update:

I did a bundle update and then ran bin/rails generate dockerfile. I still get the same error but fly logs now flag something else:

PG::ConnectionBad: FATAL: password authentication failed for user “sanuiljfszbqng”
FATAL: no pg_hba.conf entry for host “”, user “sanuiljfszbqng”, database “da2rr66k61pq44”, SSL off

Running bin/rails generate dockerfile --postgresql makes no difference.

I solved the issue by running fly launch again and using a different app name. However, there are two issues in the deployed app: the db doesn’t seem to have migrated and some of the keys are missing.

How do I run something equivalent to db:seed and db:migrate on fly?

Also, what’s the easiest way to set keys?


fly ssh console
cd /rails
bin/rails db:migrate
bin/rails db:seed

See Dockerfiles and fly.toml · Fly Docs for more details. Also Dockerfiles and fly.toml · Fly Docs may be of help.

I’m not familiar enough with Heroku to know what you mean by keys. Perhaps you mean secrets or auth token?

Thanks a lot! this worked! For some reason, running
fly ssh console -C '/rails/bin/rails db:seed' doesn’t seem to work.

Yeah, I meant secrets. I’ve used fly secrets to fix that. Thanks!

In order for that to work, the scripts need to be modified to set the current working directory. The following command will do that for you:

bin/rails generate dockerfile --bin-cd

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