Failed due to unhealthy allocations

When I am deploying I get the error Failed due to unhealthy allocations

We have a guide to troubleshooting this: https://fly.io/docs/getting-started/troubleshooting/

Normally this happens when an app is listening on 127.0.0.1, or an app is listening on a different port than internal_port in the config.

The error means the app seemed to boot ok, but we couldn’t connect to it with healthchecks.

I have tried that I also tried deleting and remaking the app

1 Like

Can you post your fly.toml? Also, what language runtime are you using? Deleting and recreating the app won’t fix this, we just need to find the right settings so it can accept network connections from us.

this is my fly.toml

fly.toml file generated for longestlist on 2020-09-10T10:29:55-04:00

app = “longestlist”

[build]
builtin = “node”

[[services]]
internal_port = 8080
protocol = “tcp”

[services.concurrency]
hard_limit = 25
soft_limit = 20

[[services.ports]]
handlers = [“http”]
port = “80”

[[services.ports]]
handlers = [“tls”, “http”]
port = “443”

[[services.tcp_checks]]
interval = 10000
timeout = 2000
`

Your app wouldn’t happen to start up and begin loading a long list from another location?

Ideally it needs to open its listening port as soon as possible so that the health checks can succeed.

Otherwise, it’ll not be responding and look unhealthy and be killed off.

also I might want to mention that this was working before and just happened with the app I installed a package. And removing the package made it work again

the package is https://www.npmjs.com/package/express-rate-limit

so should I put the app.listen at the top of the code instead of after all the app.gets and app.posts

Those aren’t going to take long and are unlikely to block the app from getting to the listener in time.

Quick check, what port is the app listening on?

  1. It works right now put some packages make it come out as unhealthy I was trying to use was https://www.npmjs.com/package/express-rate-limit ](https://www.npmjs.com/package/express-rate-limit

3000 is the wrong port. Apps with the node builtin (and most of the builtins) should be listening on port 8080. That’s why it says internal port 8080 in the fly.toml. I just deployed an node app with express-rate-limit and its responding fine over port 8080. Switch your port to 8080 or set it via the environment (we export env PORT 8080 into the node builtin) (use something like

const port= process.env.PORT || 8080;

and then app.listen(port,… later on.

that explains why it is working on 3000 because I have the process.env.PORT || 3000; I will change to 8080 and try the package again

I’ve had success deleting my builder and then running deploy again, which will allocate a new one automatically

I was hitting this issue this morning, and I tried deleting my builder and running deploy again. It ended up bricking my organization after the builder was automatically re-created, but fly deploy failed to connect to that builder from that point on.

Ended up having to create a new organization, which has been its own source of pain. Would advise caution with that tip.

1 Like