The systemd unit failed to load because the systemd daemon itself encountered an unrecoverable state while parsing the unit file.

Common Causes and Fixes:

  1. Syntax Errors in the Unit File:

    • Diagnosis: Run systemd-analyze verify /etc/systemd/system/your-unit-name.service. This command parses unit files for syntax errors without trying to activate them.
    • Fix: Examine the output of systemd-analyze verify. It will point to the exact line and character causing the problem. Common errors include missing [Unit], [Service], or [Install] sections, incorrect key-value pairs (e.g., ExecStart=/usr/bin/my-app instead of ExecStart=/usr/bin/my-app), or misplaced dependencies. Correct the syntax according to systemd unit file specifications. For example, if ExecStart is missing, add it:
      [Service]
      ExecStart=/usr/local/bin/my-daemon
      Restart=on-failure
      
      This works because systemd requires specific sections and key-value pairs to understand how to manage a service.
    • Example Error: your-unit-name.service:10: unknown directive 'ExecStartt'
    • Fix: Change ExecStartt= to ExecStart= in /etc/systemd/system/your-unit-name.service.
  2. File Permissions:

    • Diagnosis: Check the permissions of the unit file using ls -l /etc/systemd/system/your-unit-name.service.
    • Fix: Unit files must be readable by the root user. Typically, they should have permissions of 644 (owner read/write, group read, others read). Use chmod 644 /etc/systemd/system/your-unit-name.service to correct them. This ensures the systemd daemon can access and read the configuration.
  3. Incorrect File Ownership:

    • Diagnosis: Check the ownership of the unit file using ls -l /etc/systemd/system/your-unit-name.service.
    • Fix: Unit files should typically be owned by root:root. Use chown root:root /etc/systemd/system/your-unit-name.service to correct ownership. This ensures systemd, running as root, has the necessary privileges to manage the file.
  4. Missing or Malformed Dependencies:

    • Diagnosis: If your unit file has Requires=, Wants=, Before=, or After= directives, use systemctl list-dependencies your-unit-name.service to see if the listed dependencies exist and are valid units. Also, systemd-analyze verify /etc/systemd/system/your-unit-name.service will often flag invalid dependency names.
    • Fix: Ensure all units specified in dependency directives actually exist and are valid systemd units. If a dependency like network-online.target is expected but not enabled or present, you might need to install the relevant package (e.g., systemd-networkd or network-manager) and enable its corresponding service. For example, if you have Wants=my-other-service.service and my-other-service.service doesn’t exist, create it or remove the Wants= line. This works because systemd cannot load a unit that depends on a non-existent or invalid unit.
  5. Unit File Name Conventions:

    • Diagnosis: Verify that the unit file name follows the standard systemd naming conventions (e.g., my-service.service, my-device.device, my-mount.mount). The error might be subtle, like a typo or an invalid character.
    • Fix: Rename the file to adhere to systemd conventions. For instance, if you named it my service.service, rename it to my-service.service using mv /etc/systemd/system/my service.service /etc/systemd/system/my-service.service. systemd expects specific suffixes to identify the type of unit being managed.
  6. Corrupted Unit File:

    • Diagnosis: The file might appear syntactically correct but contain invisible characters or be corrupted at the byte level. Use cat -vET /etc/systemd/system/your-unit-name.service to reveal non-printable characters.
    • Fix: Recreate the unit file from scratch, carefully re-typing all content. Ensure no stray control characters or encoding issues are introduced. Copying and pasting from a known good source or text editor can sometimes introduce hidden characters. This resolves the issue by providing systemd with a clean, byte-for-byte correct configuration.
  7. Systemd Daemon State:

    • Diagnosis: In rare cases, the systemd daemon itself might be in a bad state. Check systemctl status systemd.
    • Fix: A full system reboot is often the most reliable way to reset the systemd daemon. sudo reboot. This forces systemd to re-initialize its internal state and re-scan all unit files.

After fixing any of these issues, you’ll need to run sudo systemctl daemon-reload to make systemd re-read its configuration, and then sudo systemctl start your-unit-name.service to attempt to start your service.

The next error you’ll likely encounter is a systemctl start failure if the service itself has runtime errors or if its dependencies are not met at runtime, even if the unit file loaded correctly.

Want structured learning?

Take the full Systemd course →