localhost
(a.k.a 127.0.0.1
), then Aptible cannot connect to it, so the health check won’t pass.
Indeed, your app is running in Containers, so if the app is listening on 127.0.0.1
, then it’s only routable from within those Containers, and notably, it’s not routable from the Endpoint.
To solve this issue, you need to make sure your app is listening on all interfaces. Most application servers let you do so by binding to 0.0.0.0
.
8000
, your :ref:Dockerfile
must include the following directive: EXPOSE 8000
.
443
and 80
, then the default is 443
), but you can select the port Aptible should use when creating the Endpoint and modify it at any time.
RELEASE_HEALTHCHECK_TIMEOUT
Configuration variable on your app.
There is one particular error case worth mentioning here:
[CRITICAL] WORKER TIMEOUT
[CRITICAL] WORKER TIMEOUT
errors.
These errors are generated by Gunicorn when your worker processes fail to boot within Gunicorn’s timeout. When that happens, Gunicorn terminates the worker processes, then starts over.
By default, Gunicorn’s timeout is 30 seconds. This means that if your app needs e.g., 35 seconds to boot, Gunicorn will repeatedly timeout and then restart it from scratch.
As a result, even though Aptible gives you 3 minutes to boot up (configurable with RELEASE_HEALTHCHECK_TIMEOUT
), an app that needs 35 seconds to boot will time out on the Release Health Check because Gunicorn is repeatedly killing then restarting it.
Boot up may take longer than 30 seconds and hitting the timeout is common. Besides, you might have configured the timeout with a lower value (via the --timeout
option).
There are two recommended strategies to address this problem:
--preload
flag. This option will cause Gunicorn to load your app before starting worker processes. As a result, when the worker processes are started, they don’t need to load your app, and they can immediately start listening for requests instead (which won’t time out).
--timeout
flag.
📘 If neither of the options listed above satisfies you, you can also reduce your worker count using Gunicorn’s --workers
flag, or scale up your Container to make more resources available to them.
We don’t recommend these options to address boot-up timeouts because they affect your app beyond the boot-up stage, respectively by reducing the number of available workers and increasing your bill.
That said, you should definitely consider making changes to your worker count or Container size if your app is performing poorly or Metrics are reporting you’re undersized: just don’t do it only for the sake of making the Release Health Check pass.