Troubleshooting guide
Exit code 137: what it means in Docker and Kubernetes
Exit code 137 is 128 plus 9: the process was killed with SIGKILL. Out of memory is the most common reason, but it is not the only one.
3 min read9 sectionsUpdated
On this page
Common causes
- Memory limit exceeded. The container's cgroup hit its limit and the kernel killed a process.
- Graceful shutdown timed out. The app ignored SIGTERM, so SIGKILL followed after 10 seconds in Docker or 30 in Kubernetes by default.
- A failed liveness probe causing a restart that ended this way.
- Host-level OOM.
- Manual
docker killorkill -9.
Diagnose it
Check the OOMKilled flag, then the kernel log. If the flag is false and the time near shutdown matches the grace period, your app is not handling SIGTERM.
# Docker: was it OOM?
docker inspect -f '{{.State.ExitCode}} OOM={{.State.OOMKilled}}' my-container
# Kubernetes: last termination reason
kubectl get pod my-pod -o jsonpath='{.status.containerStatuses[*].lastState.terminated}'; echo
# Kernel messages
journalctl -k --since "1 hour ago" | grep -iE 'oom|killed process'
# Does your app stop on SIGTERM?
docker stop -t 30 my-container; docker inspect -f '{{.State.ExitCode}}' my-containerFixes
If it was memory, find out whether usage is a leak or simply legitimate demand: a steady climb is a leak, a plateau above the limit means it needs more. Make runtime settings fit the limit, such as JVM -XX:MaxRAMPercentage or Node's --max-old-space-size.
If it was shutdown, handle SIGTERM and exit. In containers, a shell entrypoint often swallows signals: use exec in the script, or an init such as tini, so your process actually receives them.
Catch it automatically
Alert on container restarts and chart memory against the limit, with the deploy markers alongside. A sawtooth that ends at the limit means an out-of-memory loop. APM and infrastructure metrics let you connect the restart with the code running at the time.
Is exit code 137 always out of memory?
No. It means SIGKILL. Check the OOMKilled flag and kernel logs before concluding that memory is the cause.
What is exit code 143?
SIGTERM, 128 plus 15: the process was asked to stop and did so, which is normal during shutdown.
Why does my app take 30 seconds to stop?
It is probably not receiving or handling SIGTERM, so Kubernetes waits for the grace period and then kills it.
Related reading
- Server and Kubernetes monitoring: See CPU, memory, disk and running instances for servers, Docker containers and Kubernetes pods beside uptime checks, logs and traces, with a one-file agent.
- Docker container monitoring: Monitor Docker containers: CPU and memory against limits, restarts and health checks, container logs, and the alerts that matter on Compose hosts.
- Infrastructure monitoring: See every host, container and pod on a map coloured by CPU, memory or disk. Drill into Kubernetes, alert on CPU and memory, and start with a one-file agent.
- CreateContainerConfigError in Kubernetes: how to fix it: Fix Kubernetes CreateContainerConfigError: missing Secrets and ConfigMaps, wrong keys and namespaces, with kubectl commands that show exactly what is absent.
- Error: connect ECONNREFUSED: What connect ECONNREFUSED means and why it happens with databases, Redis and APIs, especially in Docker where localhost is the container.
- 304 Not Modified: what it means: 304 Not Modified explained: ETag and Last-Modified validation, why it makes pages faster, and fixing stale content or 304s that never refresh.
Watch your own site and services with VitalRix
Uptime checks, APM, logs, real-user monitoring, alerts and status pages in one place. Every product has a free tier and no credit card is needed.