The systemd service failed because the systemd supervisor process, systemd, couldn’t find the service’s definition file in its expected locations.

Common Causes and Fixes

1. Missing .service File

  • Diagnosis: Check if the .service file exists in the standard systemd paths: /etc/systemd/system/, /run/systemd/system/, or /usr/lib/systemd/system/.
    ls -l /etc/systemd/system/your-service-name.service
    ls -l /usr/lib/systemd/system/your-service-name.service
    
  • Fix: If the file is missing, create it. For example, for a hypothetical my-app.service:
    sudo nano /etc/systemd/system/my-app.service
    
    Add content similar to this:
    [Unit]
    Description=My Application Service
    After=network.target
    
    [Service]
    ExecStart=/usr/local/bin/my-app
    Restart=always
    User=myuser
    Group=mygroup
    
    [Install]
    WantedBy=multi-user.target
    
    This creates the necessary service definition so systemd knows how to manage your application.
  • Why it works: systemd relies on these .service files to understand how to start, stop, and manage processes. Without the file, it has no instructions.

2. Incorrect File Permissions

  • Diagnosis: Even if the file exists, systemd needs read access. Check permissions:
    ls -l /etc/systemd/system/my-app.service
    
    The typical correct permissions are rw-r--r-- (644).
  • Fix: If permissions are too restrictive, set them correctly:
    sudo chmod 644 /etc/systemd/system/my-app.service
    
    This ensures the systemd process can read the service definition.
  • Why it works: systemd runs as a specific user (often root) and needs to be able to read the service configuration files to load them.

3. Incorrect File Ownership

  • Diagnosis: The file should typically be owned by root:root.
    ls -l /etc/systemd/system/my-app.service
    
  • Fix: If ownership is incorrect, change it:
    sudo chown root:root /etc/systemd/system/my-app.service
    
    This aligns the file’s ownership with the user systemd runs as, ensuring proper access.
  • Why it works: Similar to permissions, systemd needs to access the file, and correct ownership is a prerequisite for that access.

4. Typos in the .service File

  • Diagnosis: A simple typo in the [Unit], [Service], or [Install] sections can cause systemd to reject the file. Use systemd-analyze verify to check the syntax:
    sudo systemd-analyze verify /etc/systemd/system/my-app.service
    
  • Fix: Correct any reported syntax errors in the .service file. For example, if ExecStart was misspelled as ExecStrart:
    # Incorrect
    ExecStrart=/usr/local/bin/my-app
    
    # Correct
    ExecStart=/usr/local/bin/my-app
    
    This ensures systemd can parse the file correctly.
  • Why it works: systemd has a specific format for its unit files. Any deviation, even a minor typo, prevents it from interpreting the configuration.

5. Incorrect WantedBy or Requires Directives

  • Diagnosis: The [Install] section’s WantedBy directive tells systemd which target to link the service to when systemctl enable is run. If this is incorrect or points to a non-existent target, enabling will fail.
    grep "WantedBy" /etc/systemd/system/my-app.service
    
  • Fix: Ensure WantedBy points to a valid target, commonly multi-user.target for services that should start at boot in a multi-user environment.
    [Install]
    WantedBy=multi-user.target
    
    Then, try enabling the service again:
    sudo systemctl enable my-app.service
    
    This correctly registers the service with the desired system state.
  • Why it works: The WantedBy directive is crucial for systemctl enable. It creates symbolic links in the target’s .wants directory, making the service start automatically when that target is activated.

6. Service File Not Reloaded After Changes

  • Diagnosis: If you’ve made changes to a .service file but systemd is still using the old configuration, you’ll see this error.
  • Fix: After modifying any .service file, always tell systemd to reload its configuration:
    sudo systemctl daemon-reload
    
    Then, try starting or enabling your service again.
  • Why it works: systemd caches its configuration. daemon-reload forces it to re-read all unit files from disk, picking up your recent changes.

7. File Placed in the Wrong Directory

  • Diagnosis: While less common, placing the .service file in a directory not scanned by systemd will lead to this error. The primary directories are /etc/systemd/system/ (for administrator-created units), /run/systemd/system/ (for runtime-generated units), and /usr/lib/systemd/system/ (for distribution-provided units).
  • Fix: Move the .service file to the correct location, typically /etc/systemd/system/ for custom services.
    sudo mv /path/to/your/my-app.service /etc/systemd/system/
    sudo systemctl daemon-reload
    
    This places the file where systemd expects to find administrator-managed services.
  • Why it works: systemd has a defined search path for unit files. Placing it in the correct directory ensures it’s discovered during the daemon-reload process.

After fixing these issues, the next error you’re likely to encounter if your service application itself has problems is a "failed to start" error with a specific exit code or a message indicating the executable could not be found or run.

Want structured learning?

Take the full Systemd course →