Server Container Restarts 39,352 Times: Misleading Exit Code 0 and Health Check Oversights Exposed
September 19, 2026
Main takeaway: exit code 0 is not a reliable signal of health; watch restart count as a more honest indicator of problems, and treat health checks with caution if misconfigured by ensuring they target the correct interface and port.
To prevent the loop, the fix was to enable stdin_open and tty in the compose configuration so the process keeps stdin open.
A container on a server restarted an astonishing 39,352 times with exit code 0 each time, going unnoticed because restarts weren’t crashes and the exit codes remained 0.
Root cause: a stdio mode MCP server read from stdin; without stdin_open, stdin closed at EOF caused the process to exit with 0 repeatedly, triggering the restart policy endlessly.
Implemented changes included enabling stdin_open: true and tty: true for the stdio service, adjusting health checks to target actual listening ports, ensuring health checks use IPv4 where appropriate, and adding an alert on restart velocity (restarts per hour) independent of exit code.
Two other containers were incorrectly marked unhealthy due to health checks: one checked a non-listening port, and the other failed because IPv6 localhost resolution (::1) interfered with an IPv4-only service, showing health signals can mislead when misconfigured.
Summary based on 1 source
Get a daily email with more Tech stories
Source

DEV Community • Sep 19, 2026
A container restarted 39,352 times. Every exit code was 0.