NodeJS - Failed due to unhealthy allocations

I’m trying to deploy a NodeJS app but I have no success, this is my configuration

I’ve simplified the index file to test this with a simple .get endpoint, in local it works but when trying to deploy it stays a lot with this message and then this error

==> Monitoring deployment

 1 desired, 1 placed, 0 healthy, 0 unhealthy

And the error

 1 desired, 1 placed, 0 healthy, 1 unhealthy
--> v6 failed - Failed due to unhealthy allocations - no stable job version to auto revert to and deploying as v7

--> Troubleshooting guide at https://fly.io/docs/getting-started/troubleshooting/
Error abort

Configuration files

file: fly.toml

# fly.toml file generated for api on 2022-05-04T14:49:51+02:00

app = "api"

kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[build]
  builder = "heroku/buildpacks:20"

[env]
  PORT = "8080"

[experimental]
  allowed_public_ports = []
  auto_rollback = true

[[services]]
  http_checks = []
  internal_port = 8080
  processes = ["app"]
  protocol = "tcp"
  script_checks = []

  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

  [[services.ports]]
    force_https = false
    handlers = ["http"]
    port = 8080

  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"

file: index.ts

import cors from '@koa/cors'
import Koa from 'koa'
import bodyParser from 'koa-bodyparser'
import Router from 'koa-router'

const server = new Koa()
const router = new Router({})

router.get('/', (ctx) => {
  ctx.body = { status: 1 }
})

server
  .use(cors({ credentials: true, allowHeaders: '' }))
  .use(bodyParser())
  .use(router.routes())

server.listen(8080, () => console.log(`Success`))

Try:

restart_limit = 5

Btw, DNS records for api.fly.dev are empty (which apparently should be where your app api should be, unless you’ve released public IPs fly allocates). See flyctl launch.

$ curl api.fly.dev:8080 -v
* Uses proxy env variable no_proxy == 'localhost,127.0.0.0/8,::1'
* Could not resolve host: api.fly.dev
* Closing connection 0
curl: (6) Could not resolve host: api.fly.dev
$

Apparently it was a problem with the configuration of the project having a ts builder, I added ts-node and tsc for building, served the transpiled JS and its working

The problem is that there was no error message saying what was going wrong even by adding --verbose

1 Like

The problem is that there was no error message saying what was going wrong even by adding --verbose

Those errors should have showed up in flyctl logs -a <appname>, no?

Apparently it was a problem with the configuration of the project having a ts builder

If you’re on typescript, consider Deno. It is much easier to use than Node is with typescript.

Ref: GitHub - denoland/deno_docker: Latest dockerfiles and images for Deno - alpine, centos, debian, ubuntu