49

I would like to understand what a masked service is and how to unmask it if need be.

I have been trying to start PostgreSQL on Ubuntu 16.04-LTS using the command

systemctl start postgresql.service.

Both as a user with administrative privileges, as well as root respectively.

Unfortunately, I got

Failed to start postgresql.service: Unit postgresql.service is masked.

printed in both scenarios.

Zanna
  • 70,465
Joseph-L-S
  • 1,053

4 Answers4

80

Masking a service will prevent it from starting.

To unmask a service run:

systemctl unmask name.service

Source:

How to Manage Systemd Services on a Linux System | How To Geek

Jeff
  • 1,674
  • 3
    why it is masked in the first place? I didn't do any command to mask the service! – shamaseen Aug 23 '21 at 13:09
  • 3
    Think of masked service as a disabled one, but... Disabled services are disabled in the sense that they won't be started at boot time but another service can request them to be started. Masked services can not be sated even if other services require them to start. – Ivan Marjanovic Nov 03 '21 at 13:02
3

I had an issue with mysql/mariadb services stopping suddenly then becoming masked. Running

journalctl -xe

Will generally show you ~why~ a service gets disabled/masked/won't start/etc. Generally it's for a very good reason.

In my case it was installing a new repository (for an unrelated service) that just happened to have a downgraded version of mariadb-server.
When I ran the apt upgrade, mariadb got downgraded and the service "masked"

In my case upgrading mariadb to the correct version fixed the issue and unmasked the service itself, just unmasking the service could have caused data corruption in the mysql dbs.... so basically, don't just blindly unmask something - figure out why.

1

I have found that this error message results from errors in the service creation process. Such as not naming the file .service but instead .sevrice.

I was attempting to create a service and when setting it up I sometimes transposed letters in the file extension. As a result systemd on ubuntu 21.10 reported that my service was masked and when I unmasked the service ubuntu deleted the service file like it was a thief that had been unmasked :^). Confused me for a few minutes until I saw the tranposed letters.

kkron
  • 141
0

In my case, this works for me:

sudo apt install php8.1-fpm

sudo systemctl enable php8.1-fpm

sudo systemctl start php8.1-fpm