The systemd unit you’re trying to start or enable is masked, meaning systemd has been explicitly told not to start it, even manually.
Here are the common reasons and how to fix them:
-
The unit was intentionally masked by an administrator. This is the most common scenario. An administrator might mask a service to prevent it from running altogether, perhaps due to security concerns, resource conflicts, or because it’s part of a larger system that should not be independently started.
- Diagnosis: Check if the unit file symlink points to
/dev/null.
If the output showsls -l /etc/systemd/system/your-unit.servicelrwxrwxrwx ... /dev/null, it’s masked. - Fix: Unmask the unit.
This removes the symlink tosudo systemctl unmask your-unit.service/dev/nulland allowssystemdto see the actual unit file again. You can then start or enable it.
- Diagnosis: Check if the unit file symlink points to
-
The unit is a dependency of another masked unit. If service A depends on service B, and service B is masked,
systemdwill prevent service A from starting to avoid a cascading failure or undefined state.- Diagnosis: Examine the unit file for
Requires=orWants=directives.
Look for lines likesystemctl cat your-unit.serviceRequires=masked-dependency.service. Then, check the status of that dependency:
It will likely show as "masked".systemctl status masked-dependency.service - Fix: Decide if the dependency is truly needed. If it is, unmask the dependency first (as described above). If it’s not, you can edit
your-unit.serviceto remove the dependency line, or maskyour-unit.serviceitself if it shouldn’t run without its dependency.
- Diagnosis: Examine the unit file for
-
The unit file is missing or corrupted, and
systemddefaulted to masking it. In some cases, ifsystemdcannot find or parse a unit file correctly, it might mask it to prevent errors during boot or service management. This is less common than explicit masking.- Diagnosis: Check the unit file’s existence and permissions.
Also, try loading the unit file to see ifls -l /usr/lib/systemd/system/your-unit.service ls -l /etc/systemd/system/your-unit.servicesystemdreports syntax errors.
Checksystemctl daemon-reloadjournalctl -xefor specific errors related to loading the unit. - Fix: If the unit file is legitimately missing, you’ll need to reinstall the package that provides it or create the unit file manually. If it’s corrupted, fix the syntax errors in the unit file. After making changes, run
sudo systemctl daemon-reloadto makesystemdaware of the changes.
- Diagnosis: Check the unit file’s existence and permissions.
-
A previous attempt to install or update a package failed, leaving the unit masked. Sometimes, package manager operations can be interrupted, leading to an inconsistent state where a service unit is masked but its associated package is partially installed.
- Diagnosis: Check the package status for the service.
If the package status is "half-installed" or similar, this might be the cause.dpkg -s your-package-name # For Debian/Ubuntu rpm -q your-package-name # For RHEL/CentOS/Fedora - Fix: Reinstall or reconfigure the package.
This should ensure the unit files are correctly placed and not masked by the package manager’s state.sudo apt --reinstall install your-package-name # For Debian/Ubuntu sudo dnf reinstall your-package-name # For Fedora/RHEL sudo yum reinstall your-package-name # For older RHEL/CentOS
- Diagnosis: Check the package status for the service.
-
You’re trying to start a service that is designed to be socket-activated and not directly started. Some
systemdservices are not meant to be started manually but rather are activated by asystemdsocket unit when a connection is made to a specific port.- Diagnosis: Check for a corresponding
.socketunit.
If als -l /usr/lib/systemd/system/your-unit.socket ls -l /etc/systemd/system/your-unit.socket.socketunit exists and is active (systemctl status your-unit.socket), the service is likely socket-activated. - Fix: Enable and start the socket unit instead of the service unit.
When a connection arrives at the socket,sudo systemctl enable your-unit.socket sudo systemctl start your-unit.socketsystemdwill automatically startyour-unit.service.
- Diagnosis: Check for a corresponding
-
The unit was masked as part of a system configuration or upgrade process. During major system upgrades or complex configuration changes, units might be temporarily or permanently masked to ensure a clean transition. This is often a deliberate action by system management tools or scripts.
- Diagnosis: Review system logs for recent configuration changes or upgrade-related messages.
journalctl -u systemd -f grep -i "mask" /var/log/apt/history.log # Debian/Ubuntu grep -i "mask" /var/log/dnf.log # Fedora/RHEL - Fix: If this was an intentional part of a managed process, consult the documentation for that process. If it was an unintended side-effect, you may need to unmask the unit as described in the first point.
- Diagnosis: Review system logs for recent configuration changes or upgrade-related messages.
After unmasking and ensuring the unit file is present and correct, you’ll likely need to reload the systemd daemon and then start the unit:
sudo systemctl daemon-reload
sudo systemctl start your-unit.service
The next error you’ll encounter is likely Unit your-unit.service could not be found if you try to start a service that doesn’t exist or has been removed.