Job for apache2.service failed: find the real reason in two commands
Address already in use: make_sock: could not bind to address [::]:80Short answer
The systemd message only says Apache did not start. The reason is in the Apache error log or in apache2ctl configtest. Two causes cover most cases: a syntax error in a config file, or another program already holding the port that Listen asks for. Test the config first, then check who owns the port.
Fix it fast
1Find out which cause you have
Run the config syntax test. It names the file and line of a syntax error.
sudo apache2ctl configtest2Match what you see, then jump to its fix
- 1
configtest prints a file name and line number instead of Syntax OKA configuration file has a syntax errorFix - 2
Address already in use: make_sock: could not bind to addressAnother process already listens on the portFix - 3
Apache fails right after you added a Listen directive, for example Listen 80 plus Listen 127.0.0.1:80Two Listen lines overlapFix
- 1
What does the error look like?
Address already in use: make_sock: could not bind to address [::]:80apache2.service failed (systemctl status shows the unit as failed)
Cause 1 of 3
A configuration file has a syntax error
1Check
configtest parses the config files and reports either success or the particular syntax error. It is the same as apachectl -t.
sudo apache2ctl -t2Fix
Open the file and line it names, correct the directive, then run the test again until it passes.
sudo apache2ctl configtest3Verify
Start the service once the test passes.
sudo systemctl start apache2 && systemctl is-active apache2Confirmed by httpd.apache.org
Cause 2 of 3
Another process already listens on the port
1Check
Listen decides which ports Apache binds. If another program owns the port, Apache cannot bind and exits. List the listeners on 80 and 443.
sudo ss -ltnp | grep -E ':(80|443) '2Fix
Stop the other program, or change the Listen line in /etc/apache2/ports.conf to a free port.
# /etc/apache2/ports.conf
Listen 80803Verify
Run the test and start the service.
sudo apache2ctl configtest
sudo systemctl restart apache2Confirmed by httpd.apache.org
Cause 3 of 3
Two Listen lines overlap
1Check
Overlapping Listen directives are a fatal error that stops the server from starting. Look at every Listen in the config tree.
grep -rn "^\s*Listen" /etc/apache2/2Fix
Keep one Listen per address and port combination, and remove the overlapping line.
# keep only one of these
Listen 803Verify
Test and restart.
sudo apache2ctl configtest
sudo systemctl restart apache2Confirmed by httpd.apache.org
How do I stop it coming back?
- Run apache2ctl configtest before every restart or reload; apache2ctl restart does it for you.
- Keep Listen lines only in ports.conf.
- Check ss -ltnp before moving another service onto port 80 or 443.
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.
Which stack is behind this page?
Related fixes
Servers
Apache will not restart: make_sock could not bind to address [::]:443
Address already in use: make_sock: could not bind to address [::]:443
Apache could not open port 443 because something already holds it.
2 causes, each with a fixServers
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 fixServers
Ansible hangs, then times out waiting for the sudo prompt
a playbook using become seems to hang
Ansible ran sudo on the target and never saw the answer it expected.
3 causes, each with a fixServers
Apache on Ubuntu returns 404 Not Found for my site
The requested URL was not found on this server.
On Ubuntu a 404 from Apache usually means the request maps to a path that has no file.
3 causes, each with a fixServers
Apache returns 504 Gateway Timeout when PHP takes too long
Quick requests work, slow ones end in a 504 after a fixed wait
A 504 from Apache means the backend did not answer within the proxy timeout.
2 causes, each with a fixServers
Apache logs SIGWINCH and exits on its own
the httpd container stops although nothing crashed
SIGWINCH is Apache's graceful-stop signal.
2 causes, each with a fix