When Apache2 will not start or a site will not load on Ubuntu, identify the failing layer before changing files. Check the service state, run a configuration test, read the Apache logs, then work through installation, ports, virtual hosts, modules, permissions, and TLS. This order limits downtime and gives you an error message to act on instead of a series of blind restarts.
Antihost offers Linux VPS plans with full root access, unlimited traffic on a 1 Gbps port and a 14-day free trial.
The commands below apply to the Ubuntu Apache2 package and its standard /etc/apache2/ layout. Run them with sudo and keep the first error line you see; later messages are often consequences of that original fault.
As an Amazon Associate I earn from qualifying purchases.
Quick wins for a faster PC:
Clear out junk files and repair common Windows errorsFree Scan →Fix the driver behind crashes, sound loss and screen glitchesFind Drivers →Repair Windows errors before they cause bigger problemsFix Now →Start with a five-minute triage
- Check whether the service is inactive, failed, or running.
sudo systemctl status apache2Read the first failure shown in the status output. A failed unit points to startup or configuration trouble; an active unit means the problem may be the listener, virtual-host selection, request handling, permissions, or TLS.
- Test the configuration before restarting.
sudo apache2ctl configtestA successful result is normally
Syntax OK. If Apache reports a file name, line number, unknown directive, duplicate setting, or missing include, fix that specific item before touching another configuration file. - Read both standard logs.
sudo tail -n 50 /var/log/apache2/error.log sudo tail -n 50 /var/log/apache2/access.logThe error log records startup, module, permission, and request failures. The access log records requests that reached Apache. A browser failure with no corresponding access-log entry usually means traffic is not reaching this Apache instance.
- Confirm the package and layout.
dpkg -l apache2If Apache is not installed, install it with
sudo apt updatefollowed bysudo apt install apache2. The main configuration is/etc/apache2/apache2.conf; listening ports are in/etc/apache2/ports.conf; virtual hosts are defined insites-availableand activated through links insites-enabled. - Change one layer at a time. After correcting a syntax, site, module, or TLS issue, run the configuration test again. Restart only after it passes, and if the restart still fails, return to the first new error in the status output or
error.log.
What each Apache2 state means
Inactive
An inactive unit is stopped without necessarily having crashed. It can result from an intentional stop, a failed start that left no running process, a package installation that was never started, or a boot-time service decision. Use the status output and error log to distinguish those cases; do not assume that starting it will fix an underlying configuration problem.
Failed
A failed unit means systemd attempted to run Apache and the process exited unsuccessfully. Common causes include a syntax error, an unavailable module, a port already in use, an invalid certificate path, or a permission problem while opening a file. The first error is the useful one; subsequent messages can simply describe the shutdown that followed.
#1 Best Overall
Running, but the browser still fails
An active service only proves that Apache started. It does not prove that it is listening on the interface and port you are using, that the intended virtual host is selected, that the document root is readable, or that HTTPS is configured correctly. Continue with the listener, virtual-host, permissions, and TLS checks below.
Validate configuration syntax before making more changes
apache2ctl configtest parses Apache’s configuration files and returns a success or error status. Apache also performs this check automatically before a restart, but running it directly gives you a fast, focused result without interrupting a currently working process.
Recommended Free Tools
Typical syntax failures
- Syntax error: a directive is misspelled, placed outside an allowed context, or missing a required argument.
- Could not open configuration file: an include points to a file that was moved, deleted, or never created.
- Invalid command: the directive belongs to a module that is not loaded, or the directive name is wrong for this Apache version.
- Duplicate or conflicting settings: two enabled files define incompatible listeners, virtual hosts, or module behavior.
Use the reported path and line number as your starting point. Ubuntu’s split configuration means a problem may be in apache2.conf, ports.conf, an enabled site, or a module configuration rather than in the file you most recently edited. Save a copy of a working file before making a change so that you can restore it if the test result gets worse.
Use the logs to separate startup errors from request errors
error.log: why Apache or a request failed
Ubuntu’s default error log is /var/log/apache2/error.log. Startup entries can identify an invalid directive, a missing module, a failed bind, or an unreadable certificate. Request-time entries can show a denied file, a missing path, a proxy or application failure, or a permission issue. Match the timestamp to the moment you started Apache or loaded the page.
access.log: whether the request arrived
The default transfer log is /var/log/apache2/access.log. A new line with the requested host, path, status code, and response size proves that Apache received the request. If the browser reports a timeout or connection refusal and no access entry appears, investigate DNS, firewall or network routing, the configured listener, and any service occupying the expected port rather than changing the site’s HTML.
Read the first meaningful line
Log output often contains a cascade: one root error followed by messages about child processes stopping. Start at the earliest entry generated by your action, preserve its exact wording, and correct that condition first. After the fix, generate one new request or start attempt so that old entries do not obscure the result.
Rank #2
Confirm the listener and port
Ubuntu documents Listen 80 as the normal default. The Listen directive can also include an address, so Apache may accept traffic only on a particular interface. Inspect /etc/apache2/ports.conf and compare its port and address with the URL, reverse proxy, container mapping, or load balancer that is contacting the server.
When another service owns the port
If Apache reports that it cannot bind to a port, another process may already be listening there, or Apache may have duplicate Listen entries. Stop or reconfigure the competing service only if you know it is not needed. Alternatively, select a free port and update every client or proxy that connects to Apache; changing only ports.conf will make the browser continue to contact the old port.
When Apache listens on the wrong address
A listener restricted to loopback accepts requests from the server itself but not from another machine. A listener bound to one network address will not answer on a different interface. Make the address match the interface that should serve the site, then run the syntax test before restarting.
Distinguish refusal, timeout, and an HTTP response
- Connection refused: no process is accepting the destination port, or a firewall is actively rejecting it.
- Timeout: traffic is being filtered, routed incorrectly, or sent to an address where Apache is not reachable.
- An HTTP status such as 403, 404, 503, or a default page: the request reached an HTTP server; investigate virtual-host selection, files, application handling, or TLS rather than service startup alone.
Check virtual-host selection and site enablement
Apache can be running perfectly while serving the wrong site. Confirm that the intended virtual-host file exists under /etc/apache2/sites-available/ and is enabled through sites-enabled. Enable it with:
Do these 3 things before closing this tab:
1Clear out junk files and repair common Windows errors2Scan for outdated or missing drivers - takes under a minute3Repair Windows errors before they cause bigger problemssudo a2ensite site-name
Replace site-name with the configuration file’s name, without guessing a different spelling. A typo in the file name means you may enable nothing or activate an unintended file.
Verify the host names
Inside the virtual host, check ServerName and every required ServerAlias. The name sent by the browser must match one of those values. If it does not, Apache can select another enabled host, often the distribution’s default site. DNS must also point the requested name to this server; a correct virtual host cannot receive traffic that resolves elsewhere.
Verify the document root
Check that DocumentRoot points to the directory that actually contains the site’s files. A path that does not exist, a typo in its capitalization, or a directory moved during deployment can produce a default page, a 404, or a permission error. Confirm that the configured index file is present and that the Apache worker can traverse the directory and read the files. Do not solve a permission error by making the entire filesystem world-writable.
Isolate a competing site
If several enabled hosts could answer the same name, temporarily disable the suspect or competing site:
The Tool Desk
Outbyte Driver Updater FREEFix the driver behind crashes, sound loss and screen glitchesFind Drivers →Outbyte PC Repair FREERepair Windows errors before they cause bigger problemsFix Now →sudo a2dissite site-name
Use this only as an isolation step, then test the configuration and restart once the remaining host is correct. Re-enable required sites after identifying the conflict. Disabling a site changes only that virtual-host mapping; it does not uninstall Apache or delete the file in sites-available.
Resolve module and directive problems
An error naming an unknown directive usually means the module that provides it is not loaded, although a spelling or context error is also possible. Enable the required module with:
sudo a2enmod module_name
Replace module_name with the module named by the error. If a recently enabled module is suspected, isolate it with:
sudo a2dismod module_name
Run the configuration test after either change. Modules can affect every enabled site, so record what was enabled or disabled and avoid removing a module simply because one site’s symptom appears unrelated. A module setting in a site file can fail even when the module package exists if the module is not actually loaded for the running configuration.
Rank #4
Handle HTTPS as a separate layer
HTTP on port 80 and HTTPS on port 443 can fail independently. A working HTTP virtual host does not prove that TLS is enabled, that the certificate matches the requested name, or that the private key is readable.
Enable the SSL module and site
Ubuntu’s documented path is:
sudo a2enmod ssl
sudo a2ensite default-ssl
The example site name is default-ssl; use your own SSL virtual-host file when the site has one. Confirm that the HTTPS host contains valid SSLCertificateFile and SSLCertificateKeyFile paths. The files must exist and be readable by Apache while the private key remains protected from unnecessary users.
Interpret certificate symptoms
- A missing-file error points to a wrong or deleted certificate or key path.
- A key mismatch or failed TLS startup means the certificate and private key do not form a pair.
- A browser certificate warning can indicate an expired, self-signed, or name-mismatched certificate even when Apache is listening.
- If the SSL module or site is not enabled, HTTPS may be refused while HTTP continues to work.
Test the configuration before restarting. Replace demonstration or test certificates with certificates appropriate for the production site; do not treat a browser warning as proof that the web server itself is down.
What to do about a 503 response
A 503 Service Unavailable response means an HTTP server answered but could not currently provide the requested service. Apache may be returning it because a proxied application is unavailable, a configured handler cannot start, or a maintenance rule is active. The status therefore differs from a stopped Apache service.
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 minuteWindows Errors? Fix Them Before They Spread
Repair common Windows errors and clear accumulated junk for a smoother, more stable PC - no reinstall needed.Free scan · no reinstallFirst confirm the request in access.log, then match its timestamp to error.log. If the error log names an upstream or application failure, troubleshoot that dependency and its connection settings. If it names a module, directive, or permission failure, return to the corresponding section above. Do not repeatedly restart Apache when the process is healthy and the unavailable component is elsewhere.
Why the default Apache page appears
The default page is evidence that a request reached an Apache virtual host, not evidence that your intended site is configured. The usual checks are the requested host name, enabled-site links, the order and contents of virtual-host definitions, and the DocumentRoot.
Best Value
- Confirm the browser URL uses the same hostname listed in
ServerNameorServerAlias. - Confirm DNS resolves that hostname to this Ubuntu server.
- Confirm the intended site file is enabled and the default or competing site is disabled only when it should not answer.
- Confirm the intended document root and index file exist.
- Run the configuration test and restart after it succeeds.
If the page changes when you use the server’s IP address, that is a strong indication that name-based virtual-host matching or DNS, rather than Apache startup, is the issue.
Recover safely after a bad change
Do not make several unrelated edits between tests. Use this recovery loop:
- Save the exact error from
systemctl status apache2orerror.log. - Restore the last known-good version of the file you changed, or undo only the newest directive.
- Run
sudo apache2ctl configtest. - When the result is successful, run
sudo systemctl restart apache2.service. - Make one request and inspect both logs for new entries.
If the restart fails after a successful syntax test, investigate runtime conditions such as a port collision, unavailable certificate file, or permission problem. Apache’s restart operation also performs a configuration check, so a failed restart should produce a specific status or log clue rather than requiring repeated attempts.
Choose the smallest fix that matches the evidence
| Observed layer | Useful evidence | Typical scope | First action |
|---|---|---|---|
| Service state | Inactive or failed unit in systemd status | All Apache sites | Read the first status and error-log message |
| Configuration syntax | File and line reported by apache2ctl configtest |
Usually all sites if a global file is affected | Correct the named directive or include |
| Port binding | Bind or address error; no access-log entry | Every site using that listener | Compare Listen with the requested port and competing services |
| Virtual host | Access log shows request, but wrong site or host response appears | One host name or a competing enabled site | Check ServerName, ServerAlias, enablement, and DocumentRoot |
| Module | Unknown directive or missing-module message | Any site using that directive; sometimes global | Enable or isolate the named module, then test |
| Filesystem permissions | Permission-denied entry in the error log | Usually one document root, upload path, or certificate | Verify existence, ownership, and traversal/read access without broadening permissions unnecessarily |
| TLS | HTTPS-only failure, certificate/key path or handshake error | HTTPS virtual host | Check SSL module, site, certificate, and key paths |
Commands worth keeping nearby
These are the core commands for a controlled investigation:
sudo systemctl status apache2
sudo apache2ctl configtest
sudo tail -n 50 /var/log/apache2/error.log
sudo tail -n 50 /var/log/apache2/access.log
sudo a2ensite site-name
sudo a2dissite site-name
sudo a2enmod module_name
sudo a2dismod module_name
sudo systemctl restart apache2.service
Use the enable and disable commands only for the specific site or module involved. The safest sequence is always evidence, one change, syntax test, restart, and a fresh request.
When to stop troubleshooting and escalate
Escalate with the exact service status, the configuration-test output, the first relevant error-log line, the requested hostname and port, and whether the access log recorded the request. This information lets another administrator distinguish an Apache fault from DNS, firewall, application, or certificate-management problems without asking you to repeat every experiment. Avoid sharing private keys, passwords, or full certificate contents when collecting diagnostics.
Free tools Windows power users keep installed
One-click scans. No signup required.
Quick Recap
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.




