Job for apache2.service failed. See “systemctl status apache2.service” and “journalctl -xe” for details.

We got into this apache issue when we tried to restart the apache on the Ubuntu server. The error message is quite descriptive and it provides some clues about the issue.

As soon as we ran the following apache restart command we got the error:

$ sudo service apache2 restart

Here is the error we got:

Job for apache2.service failed. See "systemctl status apache2.service" and "journalctl -xe" for details.

Reason of the issue:

The apache could not restart because we had syntax issues in one of the apache configuration files. We had to find the syntax issue in the apache configuration file.

Solution of the issue

To detect the apache configuration syntax error we had to run the following command:

$ cd /etc/apache2
$ apache2ctl configtest

It showed us the issues and the right place. When we resolved the syntax issue, the error was gone and we were able to restart the apache server.

If the above is not your case you can look into this StackOverflow article:
Unable to restart apache