systemd Service Restart Loops: Find the First Failure
Diagnose systemd restart loops, start-limit-hit and execution errors. Inspect journals and effective units, repair the cause, and verify a controlled recovery.
Find the failure that caused the first restart before changing Restart= or clearing counters. Capture status, journal entries and the effective unit, repair the execution or application problem, then perform one controlled start and verify useful work. A start-limit-hit result describes blocked starts, not the original fault.
Start with the failure, not the restart counter
A service flashes between activating and failed. The journal ends with “Start request repeated too quickly,” and another restart appears to do nothing. The tempting response is to increase the burst limit. That can turn a short incident into a longer stream of failed connections, repeated writes and noisy alerts without fixing the underlying problem.
Treat the incident as two linked questions: why did this invocation stop, and why was another invocation attempted? A missing executable explains the first question; Restart=on-failure explains the second. A deployment agent, timer or socket can also start a service, so repeated starts do not by themselves prove that the restart policy is responsible.
This procedure targets system services on Linux hosts with systemd. For a user service, use the corresponding systemctl --user and journalctl --user commands under its owning account. Check the host’s installed manual pages because distributions ship different versions. The example unit below passed offline verification with systemd 255; this article’s preparation environment had no running systemd manager, so the start, restart and journal scenarios are documentation-reviewed procedures rather than executed runtime experiments.
Capture one named unit before changing anything
Replace report-worker.service with the actual unit, including its instance name if it is a template. Collect the following read-only evidence before stopping or resetting it. status can return a nonzero exit status for an inactive or failed service; that result is evidence, not a reason to discard its output.
Use the journal window to walk backward to the first application message or process-setup error before the repeated-start warning. The current boot filter avoids mixing a previous boot’s failure into this diagnosis. Expand the time range if deployment happened earlier, and check the previous boot separately when investigating a reboot.
Copy only relevant diagnostics into an incident record. Unit files, arguments and application logs can contain credentials or customer data. Keep the original evidence in an appropriately restricted location and redact it before sharing. Record the deployment revision and approximate first-failure time alongside the service name.
systemctl status report-worker.service --no-pager --full
journalctl -u report-worker.service -b --since "30 minutes ago" --no-pager -o short-iso
systemctl show report-worker.service \
-p LoadState -p ActiveState -p SubState -p Result \
-p ExecMainCode -p ExecMainStatus -p NRestarts \
-p FragmentPath -p DropInPaths -p Restart -p RestartUSec
systemctl cat report-worker.serviceClassify the evidence before choosing a repair
The following are diagnostic branches, not interchangeable fixes. Read the journal text together with the manager properties. An exit status without its exit mechanism can be misleading: a numeric process exit code and termination by a signal are different events. Counters and the last result can also change as new invocations occur.
If the application never reached its own startup log, inspect process setup first. If it did start, follow its own error: invalid configuration, an occupied port, an unavailable dependency or rejected credentials requires a different repair from an inaccessible executable. Preserve that distinction in the incident notes.
| Evidence | First investigation | Avoid assuming |
|---|---|---|
| status=203/EXEC | Executable path, access, interpreter and executable format | That the application ran and returned its own error |
| status=200/CHDIR | WorkingDirectory existence and access in the service context | That changing the shell’s current directory fixes the unit |
| status=217/USER | Configured identity and related user setup errors | That running the service as root is the repair |
| Application exits nonzero | Its first error and configuration inputs | That a larger restart allowance makes the input valid |
| Clean exit followed by another start | Restart=always, intended process lifetime and external triggers | That every restart follows a crash |
| start-limit-hit | Earlier failure plus effective start-rate settings | That the rate limiter caused the original application failure |
| Timeout or killed process | Startup protocol, shutdown behavior and correlated host logs | That increasing every timeout or blaming OOM is justified |
Source: systemd.exec: execution environment and exit statuses ↗
A worked investigation: the worker exits after a deployment
Consider a hypothetical report worker that begins failing immediately after a release. The final journal message is about repeated starts. Earlier lines report that changing to the configured working directory failed, and the last process setup status is 200/CHDIR. The incident hypothesis should therefore be that the release path or its accessibility changed, rather than that the report parser suddenly started rejecting every job.
Compare WorkingDirectory with the deployed directory and its parent permissions. Check whether the deployment moved a release symlink, removed the previous directory too early or changed ownership. Inspect this from the service’s execution context. If the path exists for an administrator but cannot be traversed by the worker, creating another restart attempt will reproduce the same failure.
A targeted repair might restore the intended release path or correct a narrowly scoped permission. If the release is incomplete, rolling back to the last known working artifact may be the faster recovery. Either choice needs the same follow-up: verify the unit definition, start once, observe the journal and process a representative report. This example is an investigation sequence, not captured output from a real outage. Its value is the explicit chain from evidence to a falsifiable hypothesis and then to a work-level check.
Inspect the effective configuration and execution context
systemctl cat shows backing files and drop-ins on disk. systemctl show reports properties known to the manager. They can disagree after a manual file edit that has not been followed by daemon-reload. Inspect both the vendor unit and all local overrides before editing; a small drop-in can change behavior that looks correct in the main file.
Compare the executable, arguments, identity, working directory and configured environment with the deployment artifact. A service does not inherit your interactive shell setup. Virtual-environment activation, shell aliases and a successful command from your home directory do not demonstrate that the service can execute the same workload.
ExecStart is not an ordinary shell command line. Shell operators such as pipes and redirection need an explicitly invoked shell if that is truly required. Prefer an explicit executable and arguments. For scripts, inspect the interpreter named by the shebang, file format and line endings as well as the script’s executable bit. Test a repair under the intended identity without broadening permissions indiscriminately.
When a path works interactively but fails in the unit, also inspect filesystem restrictions and security-policy diagnostics. Reproducing only User= outside the unit does not reproduce its namespaces or sandbox. Use the linked Linux permission guide for directory traversal and ownership analysis, then return to the service-specific restrictions.
Source: systemctl: inspection, editing and recovery commands ↗
Contain the loop without erasing its explanation
After collecting evidence, stop the named service if the incident’s availability and data-handling requirements permit it. An explicit systemctl stop is not itself a failure that Restart= should immediately undo. However, another activation source can still start the service later.
Inspect related triggers, scheduled jobs and deployment automation if the service returns after a stop. Socket activation can start a service on incoming traffic; timer activation can start its associated unit when due. A timer does not restart an already active service simply because its time elapses. Coordinate any trigger changes rather than stopping unrelated host services.
Do not use disable as a synonym for stop: enablement concerns activation links, while current execution is a separate state. Avoid repeatedly issuing reset-failed while the cause remains present. That clears useful state and permits another attempt without changing the application or its inputs.
# Mutating operation: use only when this service may be stopped.
sudo systemctl stop report-worker.service
# Read-only follow-up for possible activation sources.
systemctl show report-worker.service -p TriggeredBy -p Triggers
systemctl list-timers --all --no-pagerSeparate restart delay from the start-rate limit
Restart= chooses which termination outcomes request automatic recovery. RestartSec= delays a restart. StartLimitIntervalSec= and StartLimitBurst= constrain starts within an interval; manual starts count too. Hitting the limit suppresses automatic attempts. Waiting for the interval to pass does not schedule a new attempt by itself, although a later eligible activation can start the unit.
A fixed delay reduces how aggressively a repeatedly failing worker retries. It does not validate configuration, make an unavailable dependency ready or give exactly-once processing. Select limits from the service’s recovery needs and downstream capacity. Do not disable rate limiting merely to make an error message disappear.
The disposable lab unit below intentionally runs /usr/bin/false, which exits unsuccessfully. Save it as pwp-restart-lab.service in a scratch directory for offline verification. It has no installation section and is not a production worker template. On a disposable systemd host, installing and starting it would intentionally generate failures; do not apply it to an existing production service.
[Unit]
Description=Prep With Proof disposable restart-policy lab
StartLimitIntervalSec=60s
StartLimitBurst=3
[Service]
Type=exec
ExecStart=/usr/bin/false
Restart=on-failure
RestartSec=2sValidate the repair before a controlled start
Run the offline check against the saved lab file, or against the real unit path on the affected host. systemd-analyze verify can detect unknown directives, missing referenced units and executable problems. Review all diagnostics rather than relying only on the exit status. It cannot prove that an application will authenticate, process a job or remain healthy.
For a real repair, preserve the existing unit and unrelated overrides. Prefer a focused drop-in created with systemctl edit when appropriate. Replacing an existing ExecStart list requires first clearing it with an empty ExecStart= assignment before specifying the replacement. Keep rate settings in [Unit] and restart settings in [Service].
After manual changes to unit files, daemon-reload makes the manager reread definitions; it does not restart the running application. systemctl edit normally reloads configuration automatically after saving. Application-specific reload is a different operation and only works when the service supports it. These distinctions prevent testing the old process while assuming it has adopted new settings.
# Offline lab-file validation; does not start the service.
systemd-analyze verify ./pwp-restart-lab.service
# Real-host recovery, after repairing and reviewing the named unit.
sudo systemctl daemon-reload
sudo systemctl reset-failed report-worker.service
sudo systemctl start report-worker.service
systemctl status report-worker.service --no-pager --full
journalctl -u report-worker.service -b --since "5 minutes ago" --no-pager -o short-isoProve recovery with useful work, not a green snapshot
Record the status and restart count immediately after the controlled start, then observe the service across a representative work interval. reset-failed clears failed state and counters, so compare measurements taken after that reset. A growing count, repeated startup messages or another start-limit-hit means recovery is incomplete.
A process being active is only one observation. Type=exec confirms that execution succeeded; it does not mean application initialization or dependency checks completed. Type=notify requires application support for readiness notification. Do not change a service to notify merely to obtain stronger-looking status output.
Validate an actual low-impact work item or the service’s documented health operation, then confirm its result at the destination. If retries may repeat writes, check the application’s deduplication and recovery behavior too. Keep evidence of the first failure, the precise repair and the successful work together. That produces a reusable diagnosis instead of a reset command that must be repeated at the next deployment.
Source: systemd.service: process lifetime and restart policy ↗
Your next steps
- Capture the first failure and loaded configuration before stopping or resetting the service.
- Repair the execution context or application input before adjusting restart policy.
- Treat offline unit verification, process activity and successful work as different levels of evidence.
Sources & official resources
Linked resources checked on 2026-10-26. Technical behavior and provider guidance can change; check the documentation for the version you use.
- systemd.service: process lifetime and restart policy ↗
- systemd.unit: start-rate limits and drop-ins ↗
- systemctl: inspection, editing and recovery commands ↗
- journalctl: unit and boot filtering ↗
- systemd.exec: execution environment and exit statuses ↗
- systemd-analyze: offline unit verification ↗
- systemd.socket: activation behavior ↗
- systemd.timer: scheduled activation ↗
About this guide and its recommendations
Published by Prep With Proof with AI-assisted drafting. Study routines and examples are editorial suggestions, not official exam instructions or claims of a learner's personal results. Cited provider facts are linked; ownership of recommended Prep With Proof products is disclosed. No competitor endorsement or guaranteed certification outcome is implied.
Suggest a correction →