Container marked unhealthy but service works
Symptom
Section titled “Symptom”A container — typically the frontend — shows unhealthy in docker ps, yet the application is reachable and serving normally in the browser. The health probe logs a “connection refused” even though the service is up.
The cause: the probe targets localhost, which resolves to both IPv6 (::1) and IPv4 (127.0.0.1). The probe tool tries IPv6 first, but the server inside the container listens on IPv4 only — so the IPv6 attempt is refused and the probe wrongly reports the container down.
Confirm
Section titled “Confirm”Check the container’s reported health versus its real reachability:
docker ps --format '{{.Names}}\t{{.Status}}' | grep aiboardIf a container reads (unhealthy) but the app responds when you hit it directly on IPv4, it is this false negative:
# from inside the container — IPv4 explicitlydocker compose -f docker-compose.release.yml exec frontend \ sh -c 'wget -qO- http://127.0.0.1:8080/ >/dev/null && echo "IPv4 OK"'If IPv4 OK prints, the service is healthy and only the probe was wrong.
Current images already probe IPv4 explicitly, so a healthy box should not hit this. If you do see it on an older image:
-
Confirm the service is actually serving (the IPv4 check above prints
IPv4 OK). If it does, no application action is needed — the container is healthy. -
Update to a current release image, where the health probe targets
127.0.0.1directly and the false negative is gone:Terminal window docker compose -f docker-compose.release.yml up -d -
Re-check the status clears:
Terminal window docker ps --format '{{.Names}}\t{{.Status}}' | grep aiboard
Prevent
Section titled “Prevent”- Probe the address the server actually binds. Health probes should target
127.0.0.1explicitly when the server listens on IPv4 only, so name resolution can’t send the probe to an unbound IPv6 address. - Distinguish probe failures from service failures. Before reacting to an
unhealthystatus, confirm with a direct IPv4 request. A green app behind a red probe is a probe bug, not an outage.
Related
Section titled “Related”- Observability & Alerts — interpreting health and status signals.