Apache Server-Status 404 Error: Configuration Fixes and Debugging Steps


4 views

When configuring Apache's server-status module, many developers encounter the frustrating 404 error despite seemingly correct configurations. Let's examine why this happens and how to properly enable this valuable monitoring tool.

First, ensure the required module is loaded in your Apache configuration:

# Check if mod_status is loaded
apachectl -M | grep status_module

# If not present, enable it
sudo a2enmod status
sudo systemctl restart apache2

The configuration snippet you provided might be incomplete. Here's a more robust version:

<IfModule mod_status.c>
    <Location /server-status>
        SetHandler server-status
        Require all granted
        # For Apache 2.2 or earlier:
        # Order deny,allow
        # Allow from all
    </Location>
</IfModule>

For more comprehensive monitoring, enable ExtendedStatus:

ExtendedStatus On

After making changes, verify your configuration:

# Check syntax
apachectl configtest

# Restart Apache
sudo systemctl restart apache2

# Test the endpoint
curl -I http://localhost/server-status

You can access different formats of server-status:

# Auto format (default)
http://yourserver/server-status

# Parsable format
http://yourserver/server-status?auto

# HTML format
http://yourserver/server-status?notable

While allowing public access is convenient for testing, in production you should restrict access:

<Location /server-status>
    SetHandler server-status
    Require ip 192.168.1.0/24
    Require host example.com
</Location>
  • Confirm mod_status is loaded
  • Verify configuration file is included (typically in /etc/apache2/mods-enabled/status.conf)
  • Check for conflicting Location directives
  • Inspect Apache error logs (tail -f /var/log/apache2/error.log)
  • Test with different client IPs if access controls are configured

Many Apache administrators encounter this frustrating scenario: you've configured mod_status with what appears to be correct syntax, yet accessing http://yourserver:port/status returns a 404 error. Let's break down why this happens and how to properly implement server status monitoring.

Before examining the configuration, verify these fundamental requirements:

# Check if mod_status is loaded
apachectl -M | grep status_module

# If not enabled (common on Debian/Ubuntu):
sudo a2enmod status
sudo systemctl restart apache2

The minimal configuration you provided might be insufficient. Here's a more robust implementation:

<IfModule mod_status.c>
    <Location "/server-status">
        SetHandler server-status
        Require all granted
        
        # Optional: Restrict access by IP
        # Require ip 192.168.1.0/24
    </Location>
    
    # Extended status provides more details
    ExtendedStatus On
</IfModule>

1. Context Matters: Place the configuration in the correct file (httpd.conf, apache2.conf, or included virtual host file), not .htaccess.

2. Path Mismatch: The URL path must exactly match your Location directive. Using /status vs /server-status makes a difference.

3. Permission Issues: Modern Apache versions often use Require all granted instead of the older Order allow,deny syntax.

After making changes:

# Check syntax without restarting
apachectl configtest

# Reload configuration
sudo systemctl reload apache2

Test with curl for better debugging:

curl -I http://localhost/server-status

You can enhance the status page with additional information:

<Location "/server-status">
    SetHandler server-status
    Require all granted
    
    # Show extended information
    ExtendedStatus On
    
    # Return machine-readable format
    SetHandler server-status
    Header Set Content-Type "text/plain"
</Location>

For programmatic access, append ?auto to get parseable output:

curl http://localhost/server-status?auto