Fly app using Heroku Postgres

Hello
I am trying to deploy a fly app using remix and a managed heroku postgres db. The app works fine locally and I can even try setting my DATABASE_URL to the heroku postgres connection string in my local dev and the app works.

However, when deploying the app it is failing on the deploy step specifically the health check step. Everything else in the deployment seems to be fine. It can connect to the database, run migrations, etc but cannot get past the health checks. The only real error message I get from the deployment is the following:

[error]Health check on port 8080 has failed. Your app is not responding properly. Services exposed on ports [80, 443] will have intermittent failures until the health check passes.

Can anyone help out on this?

Thanks!

Hi! Sorry you’re having trouble running your app. Health checks failing for a seemingly perfectly fine app is typically a sign of a misconfigured fly.toml, especially when it works locally. Health checks are just checking to see if the service is running - in this case, it’s checking to see if the server is hosting a TCP service on 0.0.0.0:8080.

Frequently, health check issues come down to either:

  1. Listening on the wrong port.
    • According to that output, your app is configured to expect a service on port 8080. Is your app listening on that port?
  2. Listening to the wrong IP address.
    • Your app should listen on 0.0.0.0. localhost or 127.0.0.1 won’t cut it for… reasons. (routing infrastructure reasons, I believe)

Running fly logs can also give you some helpful hints, as can this troubleshooting article from our docs, but you typically wouldn’t see any signs of the previous two issues in your logs.

Hi, thanks for your reply!

For 1), the app is listening to the port 8080 in production.
For 2), is there some where in the fly.toml file that specifies the this?

For reference here is what my fly.toml file contains.
I spun up the app from a remix stack and haven’t changed any of the initial configuration. The only thing different in my app compared to the remix stack is we are using a heroku managed postgres database.

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

[env]
PORT = "8080"
METRICS_PORT = "8081"

[metrics]
port = 8_081
path = "/metrics"

[deploy]
release_command = "npx prisma migrate deploy"

[experimental]
allowed_public_ports = [ ]
auto_rollback = true

[[services]]
internal_port = 8_080
processes = [ "app" ]
protocol = "tcp"
script_checks = [ ]

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

  [[services.ports]]
  handlers = [ "http" ]
  port = 80
  force_https = true

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

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

  [[services.http_checks]]
  interval = "10s"
  grace_period = "5s"
  method = "get"
  path = "/healthcheck"
  protocol = "http"
  timeout = "2s"
  tls_skip_verify = false
  headers = { }

For 2), is there some where in the fly.toml file that specifies the this?

Nope, that’s just a requirement for the platform in general. The stack you’re using is explicitly built for deploying on fly, though, so that’s surely not going to be the problem…

I’d say your best bet is looking through your logs right after trying to deploy. When everything else is configured correctly (and it seems to be!) that tends to be the next course of action.