Container shows `Up` but the app returns 502 / connection refused from the host on published port.
IntermediateTroubleshootingContainers that exit, crash or misbehave
Answer
Likely causes → App listens on 127.0.0.1 inside the container instead of 0.0.0.0, wrong container port, or the app hasn't finished booting.
Diagnose →
docker exec c ss -tlnp
docker port c
curl -v localhost:8080
Fix → Bind the app to 0.0.0.0 (e.g. flask run --host 0.0.0.0) and publish the right port.
Prevent → Add a health check hitting the published path.
More on Containers that exit, crash or misbehave
Container exits immediately with code 0 right after `docker run -d`.Beginner`Exited (137)` with no OOM flag.Intermediate`Exited (139)` segmentation fault.Advanced`Exited (126)` / `Exited (127)`.Beginner`exec /entrypoint.sh: exec format error`Intermediate`docker run` says `WARNING: The requested image's platform (linux/amd64) does not match the detected host platform (linux/arm64/v8)` and the app is very slow.Beginner