Linux systemd Service Troubleshooting: Fix Failed Services and Startup Dependencies

Systemd Service Troubleshooting

Linux services are responsible for running many of the critical components that keep a server operational. Web servers, databases, SSH, DNS services, background applications, monitoring agents, and scheduled tasks all depend on processes that must start, run, and stop correctly.

On most modern Linux distributions, systemd manages these services and controls their startup behavior, dependencies, logging integration, and recovery policies.

When a service fails, simply restarting it does not always solve the problem. The underlying cause might be an invalid unit file, incorrect permissions, a missing executable, an unavailable dependency, a port conflict, or a configuration error.

This guide explains how to troubleshoot systemd service failures step by step using systemctl, journalctl, and systemd-analyze. It includes practical examples for Ubuntu, Debian, and RHEL-based distributions, along with techniques for diagnosing failed startup dependencies, restart loops, and services that do not start during boot.

Whether you manage a single Linux server or maintain production infrastructure, these procedures will help you identify the root cause and restore services safely.

1. What Is systemd and How Does It Manage Linux Services?

systemd is a system and service manager used by many modern Linux distributions. It is typically the first user-space process started by the kernel and runs as PID 1.

Its responsibilities include:

  • Starting system services during boot.
  • Managing service dependencies and startup ordering.
  • Monitoring service processes.
  • Managing mount points, sockets, timers, and other unit types.
  • Collecting service logs through the system journal.
  • Applying restart policies and service resource controls.

systemd manages resources through configuration files called unit files.

A unit file describes how a resource should be started, stopped, or managed. The most common unit types include:

Unit TypePurposeExample
.serviceManages a service or processnginx.service
.socketManages socket-based activationsshd.socket
.timerSchedules an activationbackup.timer
.mountManages a filesystem mountdata.mount
.targetGroups units into a synchronization pointmulti-user.target
.pathMonitors filesystem pathsmyapp.path

For example, when a Linux server boots, systemd starts the units needed to reach its configured default target. Services may also be started later because another unit requires them or because a socket or timer activates them.

This dependency-based architecture makes service management flexible, but an incorrect dependency or unit configuration can prevent an application from starting.

For the broader administration context, see the Linux Server Administration Complete Guide.

2. Identify Failed Services with systemctl

The first step in systemd troubleshooting is to identify which services have failed.

The systemctl command provides information about service states, startup configuration, and dependency relationships.

2.1 List All Failed Units

Run:

sudo systemctl --failed

This displays units that systemd currently considers failed.

To show only failed services:

sudo systemctl list-units --type=service --state=failed

Example output:

UNIT                 LOAD   ACTIVE  SUB     DESCRIPTION
nginx.service        loaded failed  failed  A high performance web server
postgresql.service   loaded failed  failed  PostgreSQL database server

This gives you an initial view of the problem.

However, a failed service might be a consequence of another failure. For example, an application may fail because its required filesystem was not mounted or its database service did not start.

Do not assume that every failed service needs an independent fix.

2.2 Check a Specific Service

Use:

sudo systemctl status nginx.service

Replace nginx.service with the name of the affected unit.

The output typically includes:

  • Whether the unit file was loaded.
  • Whether the service is active, inactive, or failed.
  • The service’s main process ID, when available.
  • The most recent exit status or failure reason.
  • Recent log messages associated with the service.

For more complete output:

sudo systemctl status nginx.service --no-pager -l

The -l option prevents long log messages from being truncated.

2.3 Understand the Difference Between Service States

A systemd service can have several states.

StateMeaning
active (running)The service process is currently running.
active (exited)The unit completed successfully and remains considered active, commonly with certain oneshot configurations.
inactive (dead)The service is not currently running.
activatingsystemd is in the process of starting the service.
deactivatingsystemd is stopping the service.
failedThe service encountered a failure.

A service being inactive does not automatically mean that something is broken. Some services are started only when needed.

Also distinguish between a service being active and being enabled:

  • active describes its current runtime state.
  • enabled means it is configured to start automatically through its installation links.
  • disabled means it is not configured for automatic startup in the normal way.
  • static means it has no normal installation configuration for direct enabling.
  • masked means the unit has been linked to /dev/null and cannot be started normally.

Check whether a service is enabled:

systemctl is-enabled nginx.service

Check whether it is running:

systemctl is-active nginx.service

These checks answer different questions and should not be treated as interchangeable.

3. Diagnose Service Failures Using systemctl status

The status output is a useful starting point, but you should examine the service’s result and execution details before changing anything.

For example:

● myapp.service - Example Application
     Loaded: loaded (/etc/systemd/system/myapp.service; enabled)
     Active: failed (Result: exit-code)
    Process: 1234 ExecStart=/opt/myapp/start.sh (code=exited, status=1/FAILURE)

This indicates that systemd successfully loaded the unit file and attempted to execute the configured command, but the process exited with an error.

The next step is to investigate why the command failed.

3.1 Inspect Detailed Service Properties

Run:

systemctl show myapp.service \
  -p LoadState \
  -p ActiveState \
  -p SubState \
  -p Result \
  -p ExecMainStatus

These properties help identify whether the unit loaded correctly, what state it is in, and what result systemd recorded.

3.2 Display the Loaded Unit Configuration

Run:

systemctl cat myapp.service

This displays the main unit file and applicable drop-in configuration files.

It is particularly useful when a service behaves differently from what you expect because an administrator or software package has added an override.

Compare the configured executable, user, working directory, environment files, and dependencies with the actual application installation.

4. Find the Root Cause with journalctl

One of the most important tools for diagnosing systemd services is journalctl.

systemd integrates with the system journal, allowing administrators to inspect messages generated by services, the system manager, and the kernel.

A failed service’s status output may show only a few recent messages. The journal provides a more complete view.

4.1 View Logs for a Specific Service

Run:

sudo journalctl -u nginx.service

To display the most recent 100 entries:

sudo journalctl -u nginx.service -n 100 --no-pager

This is useful when a service fails immediately after startup.

For example, an application might report:

nginx: [emerg] bind() to 0.0.0.0:80 failed
Address already in use

This indicates that another process may already be listening on the requested address and port.

The correct response is to identify the process using the port rather than repeatedly restarting Nginx.

4.2 Inspect Logs from the Current Boot

Use:

sudo journalctl -u nginx.service -b

The -b option limits the results to the current boot.

To inspect messages from the previous boot:

sudo journalctl -u nginx.service -b -1

This is particularly useful when a service failed during system startup but was manually started successfully afterward.

Previous-boot logs are available only when the relevant journal records have been retained. Systems using volatile-only journal storage may lose those records after a reboot.

4.3 Follow Logs in Real Time

To monitor messages as they arrive:

sudo journalctl -u nginx.service -f

This is helpful when testing a configuration change or reproducing a service failure.

4.4 Investigate Warning and Error Messages

To review warning-level and more severe messages from the current boot:

sudo journalctl -b -p warning

To inspect recent service-related events with explanatory messages:

sudo journalctl -xeu nginx.service

Look for messages that appear immediately before the service transitions to the failed state.

Common clues include:

  • Permission denied
  • No such file or directory
  • Address already in use
  • Failed at step EXEC
  • Failed to load configuration
  • Dependency failed
  • Start request repeated too quickly

These messages help narrow down the investigation.

For the complete command reference, see the official journalctl documentation.

5. Understand Common systemd Service Failures and Exit Codes

systemd reports different failure results depending on which stage of service execution fails.

Understanding the error helps identify what to investigate next.

Error or Exit CodeMeaningWhat to Check
1/FAILUREApplication returned a general failure codeApplication logs and configuration
203/EXECsystemd could not execute the configured programExecutable path, permissions, interpreter, and filesystem
200/CHDIRsystemd could not change to the configured working directoryWorkingDirectory= and directory permissions
216/GROUPsystemd could not establish the configured group credentialsGroup= and group existence
217/USERsystemd could not establish the configured user credentialsUser= and account configuration
Result: timeoutA configured startup, stop, or other operation timed outApplication initialization and timeout settings
Result: dependencyA required dependency prevented startupDependency unit status and configuration
Result: exit-codeThe process or a service command exited unsuccessfullyThe exact exit status and journal entries

These systemd-specific codes are different from ordinary application exit codes. A program can also return its own non-zero exit status after starting successfully.

Example: Fix an EXEC Failure

Consider this service status:

Process: 1234 ExecStart=/opt/myapp/start.sh
(code=exited, status=203/EXEC)

Possible causes include:

  • The script does not exist.
  • The executable path is incorrect.
  • The executable permission is missing.
  • The script’s interpreter is missing.
  • The filesystem containing the executable is mounted with execution restrictions.

Inspect the file:

ls -l /opt/myapp/start.sh
file /opt/myapp/start.sh

Check the first line of a script:

head -n 1 /opt/myapp/start.sh

For a Bash script, the shebang should normally reference an available interpreter, such as:

#!/bin/bash

Check that the interpreter exists:

command -v bash

If the script is intended to be executable, correct its permissions according to the application’s security requirements:

sudo chmod 750 /opt/myapp/start.sh

Do not grant unrestricted permissions simply to make the service start. The service’s configured user must have only the access it actually needs.

6. Troubleshoot Failed Service Dependencies

A service may fail even when its own executable and configuration are correct.

The reason could be a dependency that has not started or a startup ordering problem.

systemd uses several dependency directives, including Requires=, Wants=, After=, and Before=.

6.1 Inspect Service Dependencies

Run:

systemctl list-dependencies --all myapp.service

This displays units pulled into the service’s dependency tree.

For reverse dependencies:

systemctl list-dependencies --reverse myapp.service

You can also inspect selected dependency properties:

systemctl show myapp.service \
  -p Requires \
  -p Wants \
  -p After \
  -p Before

6.2 Understand Requires, Wants, and After

These directives serve different purposes.

DirectiveFunction
Requires=Adds a stronger dependency on another unit. If the required unit fails to activate, the requesting unit generally cannot start successfully.
Wants=Adds a weaker dependency. systemd attempts to start the wanted unit, but its failure does not normally prevent the requesting unit from starting.
After=Controls startup ordering. It does not, by itself, start or require the other unit.
Before=Specifies that the current unit should be started before another unit.

A common mistake is assuming that After=database.service guarantees the database is running. It only establishes ordering when both jobs are part of the same transaction.

If an application genuinely requires a database service, its unit may need both a dependency and an ordering relationship.

For example:

[Unit]
Description=Example Application
Requires=postgresql.service
After=postgresql.service

However, this should reflect the application’s real requirements.

For applications that need a database to be available over the network, starting the database service is not necessarily proof that the database is accepting connections. The application may still need connection retries or its own readiness checks.

6.3 Investigate Network Dependencies

An application that requires network connectivity may use:

Wants=network-online.target
After=network-online.target

The network-online.target unit depends on the network manager’s wait-online implementation and configuration. It should not be treated as a universal guarantee that every remote service is reachable.

If the application connects to a remote database or API, implement appropriate connection retry and timeout handling within the application itself.

Avoid adding unnecessary dependencies to every service. Excessive or circular dependency relationships can make boot behavior more complicated.

7. Fix Incorrect systemd Unit Files and Configuration Errors

A damaged or incorrect unit file is another common cause of failed services.

Unit files are usually stored in one of the systemd unit directories.

Common locations include:

LocationPurpose
/etc/systemd/system/Administrator-created units and persistent overrides
/run/systemd/system/Runtime units and temporary configuration
/usr/lib/systemd/system/Vendor-supplied unit files on many RHEL-based systems
/lib/systemd/system/Common vendor unit location on Debian-based systems; often linked to /usr/lib on merged-usr installations

The actual search path can vary by distribution and systemd build.

7.1 Inspect the Unit File

For an administrator-managed service:

sudo cat /etc/systemd/system/myapp.service

For a packaged service:

systemctl cat nginx.service

Check for:

  • Incorrect section names.
  • Missing required settings.
  • Invalid executable paths.
  • Incorrect User= or Group= values.
  • Invalid environment file paths.
  • Incorrect working directories.
  • Unavailable dependencies.

7.2 Validate the Unit File

Use:

sudo systemd-analyze verify /etc/systemd/system/myapp.service

This checks the unit file and its referenced units for a range of configuration errors.

It can identify unknown directives, malformed configuration, and missing required dependencies.

A clean verification result does not prove that the application itself will run successfully. Application-level errors, permission problems, and unavailable resources must still be investigated.

7.3 Use Drop-in Overrides Instead of Editing Vendor Files

For a service provided by a software package, avoid directly editing its original file under /usr/lib/systemd/system/ or /lib/systemd/system/.

Package upgrades may replace vendor-managed files.

A safer method is:

sudo systemctl edit myapp.service

This creates or updates a drop-in override under the appropriate configuration directory.

For example, you might add:

[Service]
Environment="APP_MODE=production"
RestartSec=10s

After saving the editor’s changes, systemctl edit reloads systemd’s unit configuration automatically.

If you create or modify a unit file manually instead, run:

sudo systemctl daemon-reload

This instructs systemd to reload unit definitions.

Remember that daemon-reload does not restart the application process. Restart the service separately when the changed settings require it.

For more details, see the official systemd unit documentation and systemctl documentation.

8. Resolve Permission, Executable, and Environment Problems

A service can work correctly when launched manually as root but fail when systemd starts it under a restricted service account.

This often happens because systemd runs the application with a different user, group, environment, working directory, or filesystem view.

8.1 Check the Service User

Inspect the unit file for:

User=appuser
Group=appgroup

Verify that the account exists:

id appuser

Check whether the account can access the application directory:

namei -l /opt/myapp/start.sh

This command helps identify directory permissions along the path.

The service user needs execute permissions on the directories it must traverse and appropriate permissions on the files it must read or execute.

8.2 Check the Working Directory

A service may fail because its configured working directory does not exist.

Inspect the unit:

WorkingDirectory=/opt/myapp

Verify the directory:

ls -ld /opt/myapp

If systemd reports 200/CHDIR, investigate the configured working directory and its accessibility.

8.3 Check Environment Variables

Services do not automatically inherit the same interactive shell environment as an administrator.

A command that works in a terminal because the shell has configured PATH, application variables, or virtual environment settings may fail when started by systemd.

Use an environment file where appropriate:

[Service]
EnvironmentFile=/etc/myapp/myapp.env

For an optional environment file that may be absent:

EnvironmentFile=-/etc/myapp/myapp.env

The leading - tells systemd not to treat a missing file as a fatal error.

Check that the file exists when required and that the service user has the appropriate access.

Also remember that ExecStart= is not automatically executed through a shell. Shell operators such as pipes, redirection, and shell variable expansion should not be assumed to work directly in the command.

For complicated startup sequences, use a dedicated executable script with an explicit interpreter.

8.4 Check SELinux and AppArmor

Security frameworks can prevent an application from accessing files or resources even when ordinary Unix permissions appear correct.

On SELinux-enabled systems, check the current mode:

getenforce

Review recent denial messages:

sudo ausearch -m AVC,USER_AVC -ts recent

On systems using AppArmor, inspect its status and kernel messages:

sudo aa-status
sudo journalctl -k -b

Do not disable SELinux or AppArmor as a routine troubleshooting shortcut. Identify the policy denial and correct the application context or policy according to the security requirements.

9. Troubleshoot Services That Fail During Boot

A service may start successfully when an administrator runs systemctl start, yet fail during the normal boot process.

This can happen because the service starts before a required resource is ready, a mount is unavailable, the network is not initialized, or the service is not enabled for automatic startup.

9.1 Check the Default Boot Target

Run:

systemctl get-default

Common default targets include:

  • multi-user.target for a non-graphical multi-user system.
  • graphical.target for a system configured to start a graphical environment.

Inspect whether the service is enabled:

systemctl is-enabled myapp.service

If the service is intended to start automatically, enable it:

sudo systemctl enable myapp.service

To enable and start it immediately:

sudo systemctl enable --now myapp.service

Enabling a service and starting a service are separate operations. enable configures automatic activation, while start activates the service now.

9.2 Inspect Boot Logs

Review messages from the current boot:

sudo journalctl -b

To focus on warning and error messages:

sudo journalctl -b -p warning

To inspect a particular service:

sudo journalctl -u myapp.service -b --no-pager

If the service failed during the previous boot, review:

sudo journalctl -u myapp.service -b -1

9.3 Analyze Boot Dependencies and Delays

Use:

systemd-analyze blame

This lists units by the time they took to start, although a long duration does not automatically mean that a unit is broken.

To inspect the critical startup chain:

systemd-analyze critical-chain

To inspect the dependency chain for a particular unit:

systemd-analyze critical-chain myapp.service

This can help identify ordering relationships that delay service activation.

For troubleshooting services that start inconsistently during boot, Red Hat also documents cases involving systemd ordering cycles and unavailable dependencies in its service startup troubleshooting guidance.

10. Diagnose Restart Loops and Start Rate Limits

A service that repeatedly starts and stops may enter a restart loop.

This can happen when:

  • The application exits immediately after startup.
  • The configured executable fails.
  • A required resource is unavailable.
  • The application configuration is invalid.
  • A health check or watchdog causes repeated termination.
  • The service is configured to restart after every failure.

10.1 Inspect the Restart History

Run:

sudo systemctl status myapp.service
sudo journalctl -u myapp.service -n 100 --no-pager

Look for repeated start attempts and messages such as:

Start request repeated too quickly.
Failed with result 'start-limit-hit'.

This means systemd’s start rate limit has been reached.

It is a protection mechanism designed to prevent a repeatedly failing service from consuming excessive resources.

10.2 Understand Restart Settings

A long-running service may use:

[Service]
Restart=on-failure
RestartSec=5s

Restart=on-failure instructs systemd to restart the service after eligible failures.

RestartSec=5s sets the delay before a restart attempt.

The correct policy depends on the application. A service that is expected to exit successfully after completing a task should not automatically receive the same restart behavior as a continuously running web server.

10.3 Understand Start Rate Limiting

A service can also define its start rate limit:

[Unit]
StartLimitIntervalSec=60
StartLimitBurst=5

[Service]
Restart=on-failure
RestartSec=5s

This example limits repeated start attempts within the configured time window.

The precise defaults and supported directives can vary with the installed systemd version and distribution.

Do not simply increase StartLimitBurst to hide repeated failures. Identify why the process exits first.

10.4 Clear the Failed State After Correcting the Problem

After fixing the underlying issue, clear the recorded failed state and start the service:

sudo systemctl reset-failed myapp.service
sudo systemctl start myapp.service

reset-failed clears the unit’s failed state and resets its start-rate limiting counter.

It does not repair the service configuration or fix the underlying error. If the cause remains, the service will likely fail again.

11. Reload systemd Configuration and Recover Failed Units

Administrators sometimes confuse reloading systemd’s configuration with reloading an application’s configuration.

These are different operations.

Reload systemd Unit Definitions

After manually changing a unit file:

sudo systemctl daemon-reload

This tells systemd to read the updated unit definitions.

Restart a Service

To stop and start a service again:

sudo systemctl restart myapp.service

Use this when the application needs a fresh process to apply its configuration.

Reload an Application’s Configuration

Some services support reloading their configuration without a full process restart:

sudo systemctl reload nginx.service

This works only when the unit and application support a reload operation, typically through an ExecReload= command or another supported mechanism.

Enable Automatic Startup

To enable a service:

sudo systemctl enable myapp.service

To enable and start it immediately:

sudo systemctl enable --now myapp.service

Stop and Disable a Service

When appropriate:

sudo systemctl stop myapp.service
sudo systemctl disable myapp.service

Disabling a service does not necessarily stop a service that is already running. Similarly, stopping a service does not remove its automatic startup configuration.

Important: Avoid disabling, masking, or stopping critical system services unless you understand their role and have an appropriate recovery plan.

12. Practical Example: Troubleshoot a Failed Custom Linux Service

Consider a Linux server running a custom Python application.

The service is named myapp.service, and it is expected to start automatically after boot.

An administrator notices that the application is unavailable.

Step 1: Identify the Failure

Run:

sudo systemctl status myapp.service

Suppose the result shows:

Active: failed (Result: exit-code)

This confirms that the service is not running successfully.

Step 2: Inspect the Journal

Run:

sudo journalctl -u myapp.service -n 50 --no-pager

Suppose the logs show:

Failed to change to directory /opt/myapp
status=200/CHDIR

The issue is related to the configured working directory.

Step 3: Inspect the Unit Configuration

Run:

sudo systemctl cat myapp.service

Suppose the unit contains:

[Service]
User=appuser
WorkingDirectory=/opt/myapp-old
ExecStart=/usr/bin/python3 /opt/myapp/app.py

The working directory no longer exists because the application was moved.

Step 4: Verify the Actual Application Path

Run:

ls -ld /opt/myapp
ls -l /opt/myapp/app.py
id appuser

Confirm that the directory exists and that the configured service user can access it.

Step 5: Correct the Unit Using an Override

Run:

sudo systemctl edit myapp.service

Add:

[Service]
WorkingDirectory=/opt/myapp

This creates a drop-in override instead of modifying the original vendor unit.

Step 6: Restart and Verify

The systemctl edit operation reloads unit definitions after saving the override. Start the service:

sudo systemctl reset-failed myapp.service
sudo systemctl restart myapp.service

Check the result:

sudo systemctl status myapp.service

Inspect the latest logs:

sudo journalctl -u myapp.service -n 50 --no-pager

If the service is intended to start automatically, verify its enablement:

systemctl is-enabled myapp.service

This example demonstrates why reading the service logs and inspecting the unit configuration is more effective than repeatedly restarting a failed service.

13. Common systemd Troubleshooting Mistakes

Even experienced administrators can waste time by applying changes before identifying the actual failure.

Avoid the following mistakes:

Repeatedly restarting a failed service. A restart cannot fix a missing executable, invalid configuration, or denied permission.

Confusing daemon-reload with application reload. daemon-reload updates systemd’s understanding of unit files. It does not reload the application’s own configuration.

Assuming After= creates a dependency. After= defines ordering, not a requirement to start the other unit.

Editing vendor unit files directly. Package updates can replace those changes. Prefer drop-in overrides for administrator customizations.

Running everything as root. Changing User= to root may appear to solve a permission issue but can create unnecessary security exposure.

Disabling security controls to test a service. SELinux and AppArmor denials should be diagnosed and corrected rather than bypassed without justification.

Ignoring the journal. The most useful explanation is often recorded immediately before the service fails.

Increasing restart limits without investigating. This can hide a recurring application problem instead of fixing it.

14. Verify Service Recovery and Monitor Startup Behavior

After making a correction, verify that the service is healthy.

Check its runtime state:

systemctl is-active myapp.service

Check for failed units:

sudo systemctl --failed

Review the latest journal messages:

sudo journalctl -u myapp.service -n 50 --no-pager

Inspect the unit’s configuration:

systemctl cat myapp.service

If the service should start automatically, verify:

systemctl is-enabled myapp.service

For critical production services, also verify the application itself. A service can be active while the application is unable to handle requests because of an unavailable database, incorrect network configuration, or another application-level problem.

Consider monitoring:

  • Service availability.
  • Restart frequency.
  • Startup duration.
  • Application health endpoints.
  • Journal errors and warnings.
  • CPU, memory, and storage usage.
  • Dependencies required for normal operation.

A successful systemctl status is an important check, but it should not replace an application-level health test.

15. Linux systemd Troubleshooting Checklist

Use this checklist when a Linux service fails to start or behaves unexpectedly.

  • Identify failed units with systemctl --failed.

  • Inspect the affected service with systemctl status.

  • Review recent service logs using journalctl -u.

  • Check logs from the current or previous boot.

  • Inspect the loaded unit file with systemctl cat.

  • Validate custom unit files with systemd-analyze verify.

  • Check the executable path and its permissions.

  • Verify the configured User=, Group=, and WorkingDirectory=.

  • Inspect environment files and application configuration.

  • Review Requires=, Wants=, and startup ordering.

  • Check port conflicts, filesystem mounts, and network availability.

  • Investigate SELinux or AppArmor denials where applicable.

  • Check restart policies and start rate limits.

  • Run daemon-reload after manually editing unit definitions.

  • Restart the service only after correcting the underlying problem.

  • Confirm the service starts successfully and performs its intended function.

Frequently Asked Questions

Why does a systemd service fail to start?

A service can fail because of an invalid unit file, missing executable, incorrect permissions, unavailable dependency, application configuration error, port conflict, or resource problem. Start by checking systemctl status and journalctl -u.

How do I find all failed services in Linux?

Run:

sudo systemctl list-units --type=service --state=failed

To show failed units of all types, use:

sudo systemctl --failed

What is the difference between systemctl reload and daemon-reload?

systemctl reload requests that a particular application reload its own configuration, provided that the service supports it.

systemctl daemon-reload tells systemd to reload unit files and their dependencies. It does not restart the application process.

How do I view systemd logs from the previous boot?

Use:

sudo journalctl -b -1

For one specific service:

sudo journalctl -u myapp.service -b -1

Previous-boot messages must have been retained by the journal to be available.

How do I fix a service stuck in a failed state?

First identify and correct the underlying error. Then run:

sudo systemctl reset-failed myapp.service
sudo systemctl start myapp.service

Resetting the failed state alone does not repair the cause.

Why does a service start manually but fail during boot?

The service may be starting before a required dependency, mount, network resource, or configuration file is ready. Review the boot journal, dependency relationships, and startup ordering.

Conclusion

systemd provides the foundation for managing services on modern Linux servers. When a service fails, the most effective troubleshooting approach is to identify the failure state, inspect the journal, validate the unit configuration, and investigate dependencies, permissions, and startup conditions.

Commands such as systemctl status, journalctl, systemctl cat, and systemd-analyze verify provide the information needed to diagnose many common failures.

The key is to fix the underlying cause before restarting the service or changing its recovery policy.

By understanding unit files, service dependencies, execution environments, and boot behavior, Linux administrators can restore failed services more reliably and prevent the same problems from recurring.

Official Documentation and Further Reading

Leave a Reply

Your email address will not be published. Required fields are marked *