Linux
Dec 12, 2025 5 min read

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

bash
journalctl -u myapp -e --no-pager

Reset the failure counter and restart

bash
sudo systemctl reset-failed myapp && sudo systemctl restart myapp

Common unit-file fixes

ini
[Service]
User=myapp
WorkingDirectory=/opt/myapp
EnvironmentFile=/etc/myapp/env
ExecStart=/opt/myapp/bin/server
Restart=on-failure
RestartSec=5s

Frequently asked questions

Related fixes

Weekly digest

One DevOps fix in your inbox each week

Short, practical, no fluff. Real errors, real fixes — straight from production postmortems.