How to Completely Disable Built-in Apache Server on macOS for MAMP Port 80 Configuration


4 views

Even after disabling "Web Sharing" in System Preferences, many developers find the built-in Apache server still running on port 80. This creates conflicts when trying to run alternative stacks like MAMP, XAMPP, or custom configurations.

First verify if Apache is actually running:

sudo apachectl status
# Or check port 80 usage:
sudo lsof -i :80

Here's the complete solution to prevent macOS from automatically restarting Apache:

# 1. Stop Apache immediately
sudo apachectl stop

# 2. Prevent automatic launch at startup
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

# 3. Remove launchd override (important!)
sudo defaults write /System/Library/LaunchDaemons/org.apache.httpd.plist Disabled -bool true

# 4. Verify changes
sudo launchctl list | grep httpd

After completing these steps, verify port 80 is free:

netstat -an | grep LISTEN | grep -E '\.80'
curl -I http://localhost

If you encounter permission problems during this process:

# Reset launchd configuration
sudo launchctl remove org.apache.httpd
sudo launchctl unload /System/Library/LaunchDaemons/org.apache.httpd.plist

Many macOS developers face this frustrating scenario: You've unchecked "Web Sharing" in System Preferences, yet visiting localhost still shows the default Apache page. This occurs because macOS runs Apache as a launchd service independent of the GUI toggle.

First, verify Apache's status with these terminal commands:

sudo apachectl status
# Or check launchd directly:
launchctl list | grep httpd

You'll typically see output like:

...
-	0	org.apache.httpd
...

Execute these commands in sequence:

# Stop running instance
sudo apachectl stop

# Unload launchd job
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist

# For older macOS versions (10.11 and below)
sudo launchctl unload -w /System/Library/LaunchDaemons/org.apache.httpd.plist 2>/dev/null

# Prevent automatic restart
sudo launchctl disable system/org.apache.httpd

After disabling the built-in Apache, configure MAMP to use port 80:

# Verify port availability
lsof -i :80

# Edit MAMP's httpd.conf
nano /Applications/MAMP/conf/apache/httpd.conf
# Change Listen directive
Listen 80

Create a test script to ensure changes persist after reboot:

#!/bin/bash
if lsof -i :80 | grep -q httpd; then
    echo "Built-in Apache still running" >&2
    exit 1
else
    echo "Port 80 cleared for MAMP"
    exit 0
fi