15

When I try to restart apache2 by using the command:

sudo service apache2 restart

It gives me this error:

Failed to restart apache2.service: Unit apache2.service is masked.

Is this a hosting-related problem?

Zanna
  • 70,465
Vitalynx
  • 153

1 Answers1

34

A masked service is used to prevent a unwanted start of this service. If you are sure that Apache2 shouldn't be masked, you can just unmask and then restart your service with:

sudo systemctl unmask apache2
sudo service apache2 restart
ob2
  • 3,553
  • just one thing... how should one be sure if the service should not be masked if the os randomly masked it? – Florian Heigl Mar 05 '22 at 00:21
  • It's difficult to handle, there are probably many reason why a service is masked. By example if you install samba, some service is masked by default depending the way you wish to start it (as simple folder sharing, or full domain controller). – ob2 Mar 09 '22 at 15:34