Killed
This error occurs when the kernel or another process abruptly terminates a program by sending a SIGKILL (signal 9) signal.
Usually happens because:
- ☑ Physical host memory and swap allocations exhausted
- ☑ Process exceeded systemd or cgroup memory quotas
- ☑ Process was terminated by an administrator using kill -9
🔍 Quick Checklist:
What is Killed?
The 'Killed' error message is returned by the shell when a process is terminated by the kernel with a SIGKILL (Signal 9) signal. SIGKILL cannot be caught, blocked, or ignored by the application, resulting in an immediate exit. This most commonly happens because the kernel's Out-Of-Memory (OOM) Killer stepped in to terminate memory-heavy processes to prevent a system crash, or because a system administrator or timeout monitor script explicitly ran the 'kill -9' command.
Common Causes
- Kernel OOM Killer intervention: System ran out of physical memory and swap, causing the kernel to terminate the largest memory-consuming process.
- Manual process termination: An administrator or automated process manager sent a SIGKILL (signal 9) to the process.
- Systemd service memory limits: Systemd CGroups memory limits were exceeded, triggering automated process termination.
| Cause | Frequency |
|---|---|
| Kernel OOM (Out Of Memory) Killer termination | ⭐⭐⭐⭐⭐ |
| Resource constraints set by systemd CGroups | ⭐⭐⭐⭐ |
| Explicit administrative kill -9 execution | ⭐⭐⭐ |
Common Mistakes
- Running applications without memory limits in containers, leading the host operating system's OOM Killer to terminate container runtimes.
- Assuming the exit code `137` is a generic success code (exit code `137` indicates process termination by signal `9` [128 + 9]).
How to Fix
Linux Operations & Verification
Locate kernel crash messages to determine if the process was targeted by the Out-Of-Memory subsystem.
# Check system messages for memory events
$ sudo dmesg -T | grep -i -E "kill|oom"
# Look for matching line patterns:
# [Mon Jun 29 08:30:15 2026] Out of memory: Kill process 12345 (heavy_build) score 850 or sacrifice childPlatform Specific Fixes
Protect a critical process from being targeted by the OOM Killer by lowering its oom_score_adj ranking.
# Set process adjust score to lowest priority (requires root)
echo -1000 > /proc/$(pgrep -o nginx)/oom_score_adjBest Practices
- Establish memory resource constraints (`MemoryLimit` settings) in systemd service units.
- Monitor application heap usage and adjust process sizing boundaries.
Frequently Asked Questions (FAQ)
Q: What is SIGKILL (signal 9)?
SIGKILL is a system signal that forces a process to terminate immediately. Unlike SIGTERM (signal 15), the process cannot ignore this signal or run cleanup routines.
Q: How do I know if the OOM Killer killed my program?
Run 'sudo dmesg -T | grep -i oom' or check '/var/log/syslog' for logs containing 'Out of memory: Kill process'.
Q: How do I prevent the OOM Killer from targeting my app?
You can adjust its OOM score by writing to '/proc/<PID>/oom_score_adj'. Lower values make it less likely to be targeted by the kernel's cleanup routine.
Q: How do I create a swap file to prevent Killed errors?
Run: 'sudo fallocate -l 2G /swapfile && sudo chmod 600 /swapfile && sudo mkswap /swapfile && sudo swapon /swapfile'.