systemd: unit is masked
Fix the systemd 'unit is masked' error that prevents a service from starting or being enabled.
systemd: unit is masked
systemd produces "unit is masked" when a unit file is symlinked to /dev/null, preventing it from starting or being enabled.
When systemd Produces This Error
systemd reports "Failed to start {service}: Unit {service} is masked" when attempting to start or enable a masked unit. Masking is an explicit administrator action that prevents a unit from running under any circumstances.
What Causes "unit is masked" in systemd
A unit is masked when an administrator runs
systemctl mask {service}, which creates a symlink from the unit file to
/dev/null. Package scripts or system hardening tools may also mask units during installation.
How to Fix "unit is masked" in systemd
Confirm the unit is masked:
systemctl status myapp.serviceThe output shows
Loaded: masked (/dev/null; bad).Unmask the unit:
sudo systemctl unmask myapp.serviceStart and enable the service:
sudo systemctl enable --now myapp.service
How to Verify the Fix
systemctl status should show
Loaded: loaded (not
masked) and
Active: active (running).