Sometimes Apache just doesn’t start. You type in sudo systemctl start apache2
, and nothing happens. Or worse, you get an error. I’ve been there. If you’re facing this, don’t worry. In this guide, I’ll walk you through how to fix Apache not starting on Ubuntu.
We’ll keep things simple. No fancy terms. Just clear steps. Whether you’re running a small website or testing something for school, this guide is for you.
What Is Apache?
Apache is a web server. It lets people visit your website. It’s free and works well with Ubuntu. But sometimes it doesn’t start, and that’s a problem.
Before we fix it, let’s understand why it might break.
Common Reasons Apache Won’t Start
Apache not starting is often caused by:
- Port conflicts (usually port 80 or 443)
- Syntax errors in configuration files
- Another program like Nginx or Docker using the same port
- File permission problems
- Missing modules
Knowing the reason helps you fix it faster.
Step-by-Step: How I Troubleshoot Apache
Let me show you the steps I follow when Apache won’t start on my Ubuntu server.
Step 1: Check Apache Status
First, I check what Apache is doing.
sudo systemctl status apache2
If Apache failed to start, the output will usually show a red line or a message like “failed.”
Look for words like port already in use
or permission denied
. These are clues.
Step 2: Check for Port Conflicts
Apache usually uses port 80 (for HTTP) and 443 (for HTTPS). If another service is using these, Apache won’t start.
Try this:
sudo lsof -i :80
This tells you what’s using port 80. If it says something like nginx
, then Nginx is using that port.
You can also run:
sudo netstat -tuln | grep :80
Or if netstat
isn’t available:
sudo ss -tuln | grep :80
If something else is on port 80, you can either stop it, or change Apache to use a different port. But it’s usually easier to stop the other service.
For example, to stop Nginx:
sudo systemctl stop nginx
Step 3: Look at the Logs
Logs tell you what went wrong.
Run this:
sudo journalctl -xe
Or check Apache’s own log:
sudo less /var/log/apache2/error.log
Scroll through and see what error messages show up. I once found an error saying a module was missing. That helped me fix it fast.
Step 4: Test Apache Configuration
Sometimes Apache won’t start because of a small mistake in a config file.
Use this command:
sudo apachectl configtest
If everything is okay, it will say:
Syntax OK
If not, it will show where the problem is. Maybe a missing semicolon or a bad line in a virtual host.
Step 5: Restart Apache Properly
After fixing errors, try restarting Apache:
sudo systemctl restart apache2
If it works, great. If not, go back and check the steps again.
Step 6: Check File Permissions
Apache needs permission to read its files. If it doesn’t have permission, it won’t start or it will serve blank pages.
You can fix that by:
sudo chown -R www-data:www-data /var/www/html
That command gives Apache ownership of the main web folder.
Step 7: Make Sure Modules Are Enabled
Apache uses modules for things like SSL, PHP, and rewriting URLs.
If you disabled a needed module, Apache may fail.
To check enabled modules:
apache2ctl -M
To enable one:
sudo a2enmod rewrite
sudo systemctl restart apache2
You may need to enable ssl
, headers
, or others depending on what your website uses.
Tips That Helped Me
Here are two simple lists I use to remember how to check Apache issues.
Commands I Use Often:
systemctl status apache2
– check if it’s runningapachectl configtest
– check for config errorsjournalctl -xe
– view system logsless /var/log/apache2/error.log
– view Apache errorslsof -i :80
– check who is using port 80
Things to Look For:
- Is another app using port 80 or 443?
- Are there typos in the config?
- Is the file path correct?
- Are permissions set right?
- Did I forget to enable a module?
Why I Prefer Apache Over Others
Some people use Nginx instead of Apache. I’ve tried both.
Apache is:
- Easier for beginners
- Has more guides and tutorials
- Works well with .htaccess files
But Nginx is:
- Faster for static files
- Better for high traffic
If I’m just hosting a small blog, I stick with Apache. If I’m hosting a busy site or reverse proxy, I may use Nginx.
Source: Apache vs. Nginx – DigitalOcean, 2023
Still Not Working?
If you’ve done all this and Apache still won’t start, ask yourself:
- Did I edit the default config file directly?
- Did I try clearing the browser cache?
- Did I recently change DNS or domain settings?
Sometimes it’s not Apache, but something else that’s broken.
Final Thoughts
Fixing Apache not starting can feel hard at first. But once you break it down step by step, it becomes easier.
I always start with checking the service status, then the logs. Logs are your friend. They usually tell you exactly what went wrong.
Remember: Apache doesn’t break on its own. It breaks when something changes — like a new config, a new port conflict, or a missing file.
Have you run into weird Apache issues before? What worked for you?