How to Fix ‘Unit not found’ Error in systemctl on Ubuntu and Linux

Managing system services in Ubuntu, Debian, or modern Linux distributions using commands like sudo systemctl start nginx, systemctl status mysql, or systemctl restart docker only to be halted by the error: ‘Failed to start [service].service: Unit [service].service not found’ or ‘Unit [service].service could not be found’ disrupts server operations. In Linux systemd service management architecture, systemd discovers and tracks unit configuration files located inside standard system directories (/etc/systemd/system/ and /lib/systemd/system/). When an application package is not installed, the unit file has been renamed, or systemd’s in-memory dependency tree has not been reloaded, systemctl cannot locate the service.

Why Does systemctl Return ‘Unit not found’?

The unit not found error indicates that systemd evaluated all configured unit paths without discovering a matching service manifest:

  • Unreloaded systemd In-Memory Daemon Cache: Installing, creating, or modifying a service file without notifying the systemd manager via daemon-reload.
  • Service Name Mismatch or Typo: Calling a legacy or alternative service name (e.g. typing systemctl start apache instead of apache2, or mysql instead of mariadb).
  • Software Package Not Actually Installed: Attempting to start a service whose underlying binary package has not been installed via APT.
  • Masked or Orphaned Symlinks: A dangling broken symbolic link pointing to a deleted unit file.
  • Custom Unit File Missing in /etc/systemd/system/: Misplacing a custom application service file or lacking file read permissions.

Step 1: Reload the systemd Daemon Cache

Force systemd to re-scan all unit file directories and rebuild its dependency tree.

  1. Open your terminal and run:
    sudo systemctl daemon-reload
  2. Attempt to start your service again:
    sudo systemctl start service_name
  3. If the service was recently created or updated, daemon-reload registers it immediately.

Step 2: List All Available Units to Verify the Exact Service Name

Confirm the precise spelling of the service unit in systemd’s catalogue.

  1. Search systemd’s active and loaded units:
    systemctl list-unit-files --type=service | grep -i <keyword>
    (Replace <keyword> with part of your service name, e.g. nginx, apache, or postgres).
  2. Common distribution naming differences include:
    • Apache: apache2 on Ubuntu/Debian vs httpd on CentOS/RHEL.
    • PostgreSQL: postgresql instead of postgres.
    • MySQL: mariadb if using MariaDB forks.

Step 3: Verify the Software Package Is Installed

Ensure the package containing the service actually exists on your system.

  1. Check if the package is installed via APT:
    dpkg -l | grep <package_name>
  2. If no output is returned, install the package:
    sudo apt update && sudo apt install <package_name> -y
  3. Package installation automatically drops verified unit files into /lib/systemd/system/ and enables the service.

Step 4: Check for Masked Services and Broken Symlinks

If a service was masked, systemd points its symlink to /dev/null.

  1. Check unit file paths:
    file /etc/systemd/system/<service_name>.service
  2. If the output displays: symbolic link to /dev/null, the service is masked.
  3. Unmask the service:
    sudo systemctl unmask <service_name>
    sudo systemctl daemon-reload
    sudo systemctl start <service_name>

Step 5: Verify Permissions on Custom Unit Files

If you authored a custom service file, confirm correct filesystem permissions.

  1. Ensure your file is located in /etc/systemd/system/:
    ls -la /etc/systemd/system/my_service.service
  2. Ensure root ownership and standard 644 read permissions:
    sudo chown root:root /etc/systemd/system/my_service.service
    sudo chmod 644 /etc/systemd/system/my_service.service
  3. Run sudo systemctl daemon-reload and start the service.

Executing systemctl daemon-reload, verifying exact service names, installing missing packages, unmasking symlinks, and checking unit file permissions permanently resolves ‘Unit not found’ errors in systemctl on Ubuntu and Linux.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.