Do these 3 things before closing this tab:
1Repair Windows errors before they cause bigger problems2Fix the driver behind crashes, sound loss and screen glitches3Clear out junk files and repair common Windows errorsiTechGuides is reader-supported. When you buy through links on our site, we may earn an affiliate commission. As an Amazon Associate I earn from qualifying purchases. Learn more
Antihost offers Linux VPS plans with full root access, unlimited traffic on a 1 Gbps port and a 14-day free trial.
When Apache2 fails on Ubuntu, identify the failing layer before changing configuration: the service itself, configuration syntax, logs, port binding, virtual-host selection, modules, filesystem access, or TLS. Start with service status and a configuration test, then use the error and access logs to make the smallest targeted fix.
Start with a controlled diagnosis
Do not begin by repeatedly restarting Apache or editing several files at once. Capture the current state first so the original error is not buried. Work through the checks in this order:
Free tools Windows power users keep installed
One-click scans. No signup required.
- Check whether the
apache2systemd unit is running, inactive, or failed. - Validate the complete Apache configuration before attempting another restart.
- Read the error log and determine whether requests are reaching Apache in the access log.
- Confirm that Apache is installed and that you are editing the files Ubuntu actually loads.
- Check the listening port and interface.
- Verify the intended virtual host, enabled-site link, and document root.
- Resolve missing modules or directives.
- Handle HTTPS as a separate module, site, and certificate-path problem.
- Restart only after the configuration test succeeds.
This sequence separates a daemon that cannot start from a daemon that starts but serves the wrong site or cannot accept traffic.
Check Apache’s service state
Run:
sudo systemctl status apache2
Read the first failure shown in the status output and note whether the unit is inactive, failed, or active (running). A failed unit usually means startup validation, a port conflict, a missing module, a permission problem, or another fatal configuration issue. If the unit is running, the problem is more likely to be networking, virtual-host selection, the requested path, or an application behind Apache.
#1 Best Overall
Keep the exact error text. Apache and systemd often identify the file, line, directive, or port that needs attention. That evidence is more useful than a generic “Apache is not working” description.
Validate configuration syntax before changing anything else
Run the Apache configuration check:
sudo apache2ctl configtest
The apache2ctl script checks the loaded configuration files and returns a success or error status. A valid configuration commonly reports Syntax OK; a failure identifies the file and line that Apache cannot parse. Correct that specific problem, then run configtest again. Do not proceed to repeated restarts while this check is failing.
The Tool Desk
Outbyte PC Repair FREEClear out junk files and repair common Windows errorsFree Scan →Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Typical syntax failures include a misspelled directive, an included file that no longer exists, an unclosed virtual-host block, a duplicate or invalid argument, or a directive supplied by a module that is not enabled. The error message determines which category applies, so preserve it rather than replacing configuration wholesale.
Use the logs to distinguish startup failures from request failures
Ubuntu’s default Apache logs are:
/var/log/apache2/error.logfor startup, module, permission, and request errors./var/log/apache2/access.logfor requests Apache receives.
Inspect the most recent entries after reproducing the problem:
sudo tail -n 50 /var/log/apache2/error.log
sudo tail -n 50 /var/log/apache2/access.log
If the access log gets a new entry when you load the site, traffic reached Apache; investigate the selected virtual host, requested resource, permissions, or an upstream configuration. If no access entry appears, look earlier in the chain: DNS or the address being used, firewalling, the listening port, interface binding, or a service that owns the port.
Rank #2
The error log is the authoritative place to look for a failed startup, an unavailable module, an unreadable certificate, a denied file, or an error while handling a request. Ubuntu documents /var/log/apache2/error.log as the default error destination through the ErrorLog directive. A custom virtual host can override that path, so check the relevant site definition if its messages are not in the global file.
Crashes, No Sound, or Screen Glitches?
Random freezes, missing sound and display glitches usually trace back to one bad driver. Find and replace yours safely.Free scan · under a minutePC Slower Than It Used to Be?
A free scan shows the junk files, broken settings and background clutter dragging Windows down - then fixes them in one click.Free scan · Windows 10 & 11Confirm installation and Ubuntu’s configuration layout
If the command is missing or the service unit does not exist, install Apache2 from Ubuntu’s package repository:
sudo apt update
sudo apt install apache2
On a normal Ubuntu installation, the main configuration is under /etc/apache2/:
| Location | Purpose | What to verify |
|---|---|---|
/etc/apache2/apache2.conf |
Global Apache configuration | Global includes and settings have not been removed or malformed. |
/etc/apache2/ports.conf |
Listening-port directives | The Listen value matches the port and interface clients use. |
/etc/apache2/sites-available/ |
Virtual-host definitions | The intended site file exists and contains the expected host and document root. |
/etc/apache2/sites-enabled/ |
Enabled virtual-host links | The intended site is linked here, and an unwanted competing site is not taking precedence. |
Editing a file in sites-available does not activate it by itself. Ubuntu loads the definitions represented in sites-enabled; use the site-management commands in the virtual-host section to change that set.
Check the listening port and network interface
Ubuntu’s documented normal default is Listen 80. Open /etc/apache2/ports.conf and check every Listen directive. The port must match the URL’s explicit port, and an address-qualified directive must include an interface reachable from the client. A directive limited to loopback can make Apache appear down from another machine even though the service is running.
Also consider a port conflict. Another daemon may already own port 80 (or the alternate port you configured), preventing Apache from binding during startup. The first error in systemctl status apache2 or /var/log/apache2/error.log usually names the address and port that failed. Stop or reconfigure the competing service only after confirming that it is the process you intend to move; changing Apache’s port affects every site that depends on that listener.
When testing from a browser, compare the address and port you actually reach with the Listen directives. Testing http://server.example/ uses port 80, while an alternate port must be written explicitly in the URL.
Verify virtual-host selection
A running Apache can still show the wrong page, a default page, or an error because the request matched a different virtual host. Check these four items in the site definition:
- File and enabled link: the intended definition exists in
sites-availableand is enabled insites-enabled. ServerName: matches the hostname in the request.ServerAlias: includes additional names that should reach the same site.DocumentRoot: points to an existing directory containing the expected files.
Enable a site with:
sudo a2ensite site-name
Replace site-name with the configuration filename without its .conf suffix. To isolate a suspected competing definition, disable it temporarily:
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Scan for outdated or missing drivers - takes under a minuteDriver Scan →Repair Windows errors before they cause bigger problemsFix Now →sudo a2dissite site-name
Run sudo apache2ctl configtest after each change. Once it succeeds, restart Apache and test with the exact hostname that appears in ServerName or ServerAlias. If the browser still receives the default page, verify that the requested hostname resolves to this server and that the intended site is enabled rather than only stored in sites-available.
Rank #4
Resolve missing directives and modules
An error such as “Invalid command” or a message naming an unavailable module means Apache does not know the directive in the file being loaded. Enable the required module:
sudo a2enmod module_name
Replace module_name with the module identified by the error. To isolate a module suspected of causing a failure, disable it:
sudo a2dismod module_name
After enabling or disabling a module, run sudo apache2ctl configtest. A module change can affect every enabled site, not just the site you were editing, so inspect the error log and test the other virtual hosts after Apache comes back.
Treat HTTPS as a separate troubleshooting path
HTTP working does not prove that HTTPS is configured. Ubuntu’s documented HTTPS path requires the SSL module, an enabled SSL virtual host, and valid certificate and key paths.
- Enable SSL support:
sudo a2enmod ssl - Enable an SSL site, such as Ubuntu’s
default-ssldefinition:sudo a2ensite default-ssl - In the SSL virtual host, verify that
SSLCertificateFilepoints to the certificate andSSLCertificateKeyFilepoints to its private key. - Run
sudo apache2ctl configtestand correct any path, permission, or syntax error before restarting.
A missing file, unreadable key, or incorrect path prevents the SSL site from loading even when ordinary HTTP works. Test certificates are suitable only for controlled testing; use certificates appropriate for the hostname and deployment before exposing the service to users.
Best Value
Check document-root and filesystem access errors
The error log distinguishes a missing path from a denied path. First confirm that the DocumentRoot directory named by the selected virtual host actually exists. Then inspect the path components and the requested file for permissions that prevent Apache from reading them. A site can fail after a configuration change if the document root was moved, deleted, mounted late, or made inaccessible to the account running Apache.
Do not “fix” a permission error by making the entire web tree writable. Change only the ownership or read/execute permissions required by the site, and preserve restrictive permissions for private keys and other secrets. Re-run the request while watching error.log; the new entry should show whether the denied path is the document root, a directory above it, or a specific file.
What’s actually slowing this PC down?
Pick the symptom - the matching free tool is one click away.
Restart only after validation
Once the relevant change is made and the configuration test succeeds, restart the service:
sudo systemctl restart apache2.service
Apache performs a configuration check as part of a restart, but running apache2ctl configtest first gives you a clear result before interrupting a working process. If the restart fails, return to the exact first error in the systemd status output or error.log. Repeated restarts do not repair a syntax, port, module, virtual-host, permission, or certificate problem.
Quick Recap
Use the symptom to choose the next check
| Observed symptom | Most useful evidence | First place to investigate | Typical scope of the change |
|---|---|---|---|
| Service is failed or will not start | systemctl status apache2, then apache2ctl configtest |
The first named file, line, directive, module, or port in the error | Often global or affects every enabled site; validate before restart |
| Browser cannot connect | Service state, ports.conf, and whether an access-log entry appears |
Listen port/interface or a competing listener |
Usually affects every site on that listener |
| Default Apache page appears | Enabled-site links and the request hostname | ServerName, ServerAlias, and competing enabled sites |
Usually one hostname or virtual-host selection |
| Site returns an error after a request reaches Apache | access.log paired with the corresponding error.log entry |
Selected virtual host, document root, permissions, or a directive/module named in the error | Can be one site or global, depending on the directive |
| HTTPS fails while HTTP works | SSL virtual-host configuration and certificate/key errors | SSL module, enabled SSL site, and SSLCertificateFile/SSLCertificateKeyFile |
Normally the HTTPS site, but the SSL module is shared |
A practical recovery checklist
- Record
sudo systemctl status apache2before editing. - Run
sudo apache2ctl configtestand fix the named error. - Read recent entries in
/var/log/apache2/error.log. - Use
/var/log/apache2/access.logto establish whether the request reached Apache. - Confirm Apache2 is installed and inspect the files under
/etc/apache2/. - Verify
Listenand the address and port used by the client. - Check the intended site’s enabled link,
ServerName,ServerAlias, andDocumentRoot. - Enable or disable a module only when the error identifies it, then test syntax again.
- For HTTPS, check the SSL module, SSL site, certificate path, and key path independently.
- Restart once the test passes, then verify the same hostname, port, and protocol that originally failed.
Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

