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?

  • What version of Ubuntu is this? – George Udosen Sep 26 '17 at 22:45
  • version 17.04 @George – Vitalynx Oct 1 '17 at 11:29
  • 1
    I had the same issue after upgrading to 18.04. I found the command to unmask the service. But still one thing is not resolved: Why did apache2 get into this masked state? I could not find a reason up to now. – guettli Oct 22 '18 at 5:02

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.