Fixing-Unable to start service apache2 Job for apache2.service failed because the control process exited with error code?
Many companies utilize the well-known open-source web server Apache2 to host websites and applications. You might experience a problem where the service cannot be started and you see an error message like "Unable to start service apache2: Job for apache2.service failed because the control process exited with error code".
Whether you are installing Apache2 manually or using Ansible to automate the process. I will walk you through the troubleshooting procedures to resolve this issue in this post.
Here are some screenshots I have taken when I was trying to start Apache2 Service -
Ansible Playbook failed to start Apache2 service
Manually starting Apache2 service also failed
In this article, we will guide you through the troubleshooting steps to fix this issue.
1. Check any port conflicts
Conflicting ports can also prevent the Apache2 service from starting and it is one of the most common issue
To find processes utilizing the same port as Apache2, use the
netstat -tlnp | grep ":80" command.
If there is a conflict, you may either terminate the infringing service or modify the configuration files to alter the port that Apache2 uses.
Here is the screenshot where I am checking if there is any process which has already occupied the port 80 -
- Kill the process running on the port using the command
kill -9 <process-id>
- Update the apache config located
/etc/apache2/apache2.confand assign different port for the apache2 service.
2. Check the Apache2 Error Log
When the Apache2 service fails to start, the second place to look is the error log file located at
Check the log for any error messages that may indicate the cause of the failure.
3. Validate apache2.conf for Configuration Errors
If the configuration files include mistakes, the Apache2 service can be unable to start.
To examine the configuration files for syntax issues, use the
apachectl configtest command. The configuration files can be edited to correct any issues.
apache2.conf is correct then you should see following message -
4. Start the Server again
Starting-service problems can occasionally be resolved by simply restarting the server.
Here is the command to restart the apache2 service -
1sudo systemctl restart apache2
5. Install Apache2 again
You might need to reinstall Apache2 if the aforementioned solutions don't resolve the problem.
You may uninstall the program with the command -
1sudo apt-get remove apache2
After remove the apache2 you can reinstall it with the command -
1sudo apt-get install apache2
Although setting up and operating Apache2 might be simple, problems can arise if the service doesn't start.
You may use the troubleshooting instructions in this article to help you resolve the "Unable to start service apache2: Job for apache2.service failed because the control process exited with error code" fault while installing Apache2 manually or using Ansible.
You should be able to set up Apache2 quickly by following these instructions.
Posts in this Series
- How to Use SSH Keys with Ansible for Secure Server Management?
- Why YAML is so important in Ansible?
- Clone Public and Private Git Repositories with Ansible
- How to Limit Ansible playbook on Hosts, Groups and multiple hosts?
- Easy Fix for 'zsh command not found ansible' Error After Installing Ansible with Pip
- Demystifying Hosts, Inventory Roles, and Tasks
- Fixing-Unable to start service apache2 Job for apache2.service failed because the control process exited with error code?
- Why Ansible is the Ultimate Tool for DevOps Teams - A Beginner's Guide?
- Ansible how to fix destination path already exists and is not an empty directory?
- Install Ansible on MacOS, Windows, Ubuntu(debian) and Fedora(rpm) - Part 1