Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

Apache will not start: could not bind to address [::]:80

Error(48)Address already in use: AH00072: make_sock: could not bind to address [::]:80

Short answer

Apache asked the system for port 80 and the system said it is taken. Either another program already listens there, often a second Apache, or two Listen lines in your config overlap. Find the owner of the port with lsof, stop it or move Apache to another port, then run apachectl configtest and start again.

  • Applies to Apache httpd 2.4, macOS
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    Ask the system who owns port 80 right now. If nothing is listed, the problem is in the Listen lines.

    sudo lsof -i:80
  2. 2Match what you see, then jump to its fix

    1. 1lsof lists a process (httpd, nginx or a dev server) in LISTEN state on port 80Another web server or a second Apache already uses port 80Fix
    2. 2lsof shows nothing on port 80, but the config has more than one Listen for the same portTwo Listen directives overlapFix
    3. 3The error appears right after a stop, and a second start a few seconds later worksApache was stopped and started again too fastFix
    4. 4The error mentions a permission problem with ports under 1024 instead of a busy portApache is not started as root and the port is below 1024Fix

What does the error look like?

  • (48)Address already in use: AH00072: make_sock: could not bind to address [::]:80
  • (48)Address already in use: AH00072: make_sock: could not bind to address 0.0.0.0:80

Cause 1 of 4

Another web server or a second Apache already uses port 80

1Check

The Apache wiki's first cause is that the address is taken, including by another httpd. On Mac OS X it names lsof and netstat to find the process.

sudo lsof -i:80
netstat -Wan | grep 80

2Fix

Stop that program, or change the port Apache uses. If Apache itself is the listener, stop it with apachectl before you start it again.

sudo apachectl stop
# or change the port in httpd.conf
Listen 8080

3Verify

Check the config, start Apache and confirm it is listening.

apachectl configtest
sudo apachectl start
sudo lsof -i:80

Confirmed by cwiki.apache.org

Did this fix it?

Cause 2 of 4

Two Listen directives overlap

1Check

Overlapping Listen directives are a fatal error. A wildcard such as Listen 80 binds the port on every address, so a second Listen 127.0.0.1:80 conflicts with it. Included files count too.

grep -rn "^Listen" /etc/apache2/ /usr/local/etc/httpd/ 2>/dev/null

2Fix

Keep one Listen per port. Use either the bare port or the specific address, not both.

# keep one of these, not both
Listen 80
# Listen 127.0.0.1:80

3Verify

Stop and then start Apache; the docs say Listen changes need a full stop and start, not a restart.

apachectl configtest
sudo apachectl stop
sudo apachectl start

Confirmed by httpd.apache.org

Did this fix it?

Cause 3 of 4

Apache was stopped and started again too fast

1Check

The Apache wiki lists a rapid stop and start as a cause. The old process may still hold the socket for a moment.

sudo lsof -i:80

2Fix

Use apachectl restart, or wait a few seconds between the stop and the start.

sudo apachectl restart

3Verify

Apache stays up and answers on port 80.

curl -I http://localhost

Confirmed by cwiki.apache.org

Did this fix it?

Cause 4 of 4

Apache is not started as root and the port is below 1024

1Check

On Unix-based systems, non-root users cannot bind ports below 1024. The wiki's fix is to start Apache as root.

id -u

2Fix

Start Apache with sudo, or use a port above 1023 for development.

sudo apachectl start

3Verify

Apache starts and lsof shows httpd on the port.

sudo lsof -i:80

Confirmed by cwiki.apache.org

Did this fix it?

How do I stop it coming back?

  • Run only one local web server on port 80, and switch the others to 8080 or another free port.
  • Always run apachectl configtest before starting or restarting.
  • Keep Listen in one config file only, and avoid repeating it in included files.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Related fixes

Servers

dnf cannot install MySQL on Amazon Linux 2023

dnf cannot find a mysql-server package on Amazon Linux 2023

Amazon Linux 2023 documents MariaDB, not MySQL, as its database server, with packages named mariadb105 and mariadb105-server.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.