Debug a Failed systemd Service
From `Active: failed` to a clean restart — how to read systemd logs and fix unit files.
Problem
`systemctl status myapp` shows `Active: failed (Result: exit-code)` and the service won't stay up.
Root cause
- The ExecStart command exits non-zero.
- Missing user, working directory, or env file.
- SELinux or AppArmor denies the action.
- Restart= policy gives up after too many retries.
Solution
Read the actual error
journalctl -u myapp -e --no-pagerReset the failure counter and restart
sudo systemctl reset-failed myapp && sudo systemctl restart myappCommon unit-file fixes
[Service]
User=myapp
WorkingDirectory=/opt/myapp
EnvironmentFile=/etc/myapp/env
ExecStart=/opt/myapp/bin/server
Restart=on-failure
RestartSec=5sFrequently asked questions
Related fixes
Linux
5 minFix "Too many open files" on Linux
Raise the open file descriptor limit the right way — per process, per user, and system-wide.
#ulimit#systemd#nofile
Linux
4 minFix "Permission denied" Binding to Port 80 or 443 on Linux
Bind to privileged ports without running your app as root, using capabilities or sysctl.
#networking#capabilities#ports
Weekly digest
One DevOps fix in your inbox each week
Short, practical, no fluff. Real errors, real fixes — straight from production postmortems.