/commands/systemd/systemctl-list-failed-units
systemctl --failed: list failed services and see why
- tool
- systemd
- versions
- systemd 2xx
- os
- linux
systemctl --failed (short for systemctl list-units --state=failed) lists every unit that is in the failed state. For each one, systemctl status NAME shows the last log lines and the exit code, and journalctl -u NAME -b shows its full log since the last boot. After fixing the cause, systemctl reset-failed NAME clears the failed state.
List failed units
systemctl --failed
systemctl list-units --state=failed --type=service # services only
systemctl --user --failed # units of your user manager
systemctl is-failed nginx.service # prints "failed" and exits 0 if failedFind out why a unit failed
systemctl status nginx.service # state, main PID, exit code, last 10 log lines
journalctl -u nginx.service -b # all log lines for the unit since boot
journalctl -u nginx.service -n 50 --no-pager
journalctl -u nginx.service -f # follow new lines
journalctl -xeu nginx.service # jump to the end, with explanationsThe Main PID line of systemctl status shows how the process ended, for example code=exited, status=1/FAILURE (the program exited with status 1) or code=killed, signal=KILL. Result: values such as exit-code, signal, timeout, core-dump and start-limit-hit tell you which rule marked the unit as failed.
Common results
| Result | Meaning | Where to look |
|---|---|---|
| exit-code | The main process exited with a non-zero status | The program log: journalctl -u NAME |
| signal | The process was killed by a signal | OOM killer messages: journalctl -k -b | grep -i oom |
| timeout | Start or stop took longer than TimeoutStartSec / TimeoutStopSec | Slow start-up, or Type= does not match the program |
| start-limit-hit | The unit restarted too often (StartLimitBurst within StartLimitIntervalSec) | The first failure in the log, then reset-failed |
| core-dump | The process crashed and dumped core | coredumpctl list |
After fixing it
systemctl daemon-reload # only if you edited a unit file
systemctl reset-failed nginx.service # clear the failed state and the start-limit counter
systemctl restart nginx.service
systemctl status nginx.serviceCommands that change units (restart, reset-failed, daemon-reload) need root for system units: run them with sudo.