Guide
Diagnosing and Fixing Systemd Service Failures from Unit File Misconfigurations
When a systemd service stops immediately with ExitCode 1 or 255, the culprit is often a mis‑configured unit file. This guide walks through the symptoms, common causes, a step‑by‑step diagnostic checklist, and proven fixes so you can restore service uptime quickly.
Published by Tasadduq Burney
02 Jul 2026, 03:57 UTC
4 min80.8K views0

Recognizable Symptoms
A service that fails to start often shows the same quick‑fire pattern:
systemctl status myservicereportsActive: failed (Result: exit-code)withExitCode=1or255.- The status output contains a short message like
Unit file … is missing or invalidorFailed to start …: ExecStart=… failed with exit code 1. - Running
journalctl -u myservicereveals lines such asConditionFileNotEmpty=…: falseorConditionPathExists=…: false.
Common Causes
| Cause | Typical Indicator |
|---|---|
| Condition directives evaluate to false | ConditionFileNotEmpty, ConditionPathExists, etc. show "false" in journal |
| ExecStart path is wrong or the binary is missing | "Failed to start …: ExecStart=… failed with exit code 1" or "no such file or directory" |
| Executable lacks execute permission or wrong owner | Permission denied errors in journal; ls‑l shows no x bit |
| Unit file permissions prevent systemd from reading it | systemd reports unit file not readable, or status shows "Invalid unit file" |
| Security options block required files (e.g., PrivateTmp, ProtectSystem) | Permission errors for files the service needs |
Diagnostic Checklist
- Check the status
Verifysystemctl status myserviceActive:andExitCode. - View recent logs
Look for Condition failures, ExecStart errors, or permission messages.journalctl -u myservice --since today - Inspect the unit file
Confirmsystemctl cat myserviceExecStartpath, Condition lines, and security options. - Verify file existence and permissions
Ensure the unit file is readable by root and the executable is executable.ls -l /etc/systemd/system/myservice.service ls -l /usr/bin/myservice - Test condition paths manually
IfConditionPathExists=/var/run/myservice.sock, check:test -e /var/run/myservice.sock && echo exists || echo missing - Check security context
IfProtectSystem=fullis set, the service cannot write to /etc. Verify required files are in allowed directories.
Fixes Tied to Findings
- False Condition – Edit the unit file to correct the path or remove the directive if unnecessary. Example:
If the file is missing, create it or adjust the condition.[Unit] ConditionPathExists=/etc/myapp/config.yaml - Bad ExecStart – Ensure the path points to an existing, executable binary. Add the full path or use
$PATHcarefully.[Service] ExecStart=/usr/bin/myapp --config /etc/myapp/config.yaml - Permission issues – Set correct ownership and mode:
For the unit file,chown root:root /usr/bin/myapp chmod 755 /usr/bin/myappchmod 644 /etc/systemd/system/myservice.service. - Security options blocking access – Adjust
PrivateTmp=yes,ProtectSystem=full, orReadOnlyDirectories=/etcto allow the service to touch required files. Alternatively, move necessary files into/var/tmpor a directory listed inReadWriteDirectories=. - Unit file cache – After changes, run:
Then re‑check status.systemctl daemon-reload systemctl restart myservice
Escalation Criteria
If after applying the fixes the service still fails:
- Check for hidden dependencies:
Requires=orAfter=directives that might be pulling in other units that fail. - Inspect SELinux/AppArmor logs if enabled; a policy denial can masquerade as a unit failure.
- Verify that the system has sufficient resources (memory, disk, inodes) and that no cgroup limits are preventing start.
- If the unit uses templating (e.g.,
myservice@.service), confirm the instance name matches the expected configuration.
Practical Example
Suppose myapp.service fails with ExitCode=1. The unit file contains:
[Unit]
Description=My App
ConditionFileNotEmpty=/etc/myapp/config.yaml
[Service]
ExecStart=/usr/local/bin/myapp
User=nobody
[Install]
WantedBy=multi-user.target
- Run
systemctl status myapp→ showsConditionFileNotEmpty=…: false. - Check the file:
ls -l /etc/myapp/config.yaml→ file missing. - Create the file or remove the condition if the app can run without it.
- Reload and restart:
systemctl daemon-reload && systemctl restart myapp. - Verify with
systemctl status myapp→ nowActive: active (running).
Verification Checklist
- Confirm
systemctl status myserviceshowsActive: active (running)andExitCode=0. - Review
journalctl -u myservice --since todayfor no error lines. - Run
systemctl show myserviceto ensure the active unit file path matches the edited one. - If the service writes logs to a file, check that the file exists and is writable.
Limitations and Caveats
- Systemd can cache unit files; stale configurations may persist until
daemon-reloadis executed. - Changing security options can expose the system to new attack vectors; apply the minimal necessary permissions.
- When using templated units, instance names must match the file name pattern; mismatches silently result in a stopped unit.
- Some failures may be caused by external factors (e.g., disk space, memory limits) that are not evident in the unit file alone.
Practical Check
After making a change, run:
systemctl status myservice
journalctl -u myservice --since now | tail -n 20
These commands provide a quick snapshot of the current state and recent events.
0 replies
A thoughtful contribution can make all the difference. Be the first to share one.