Apache HTTPD: Address already in use: make_sock: could not bind to address 0.0.0.0:443
During my latest Apache configuration change I ran into an issue where I wasn’t able to restart/start. This was the first time I encountered this and I was fairly positive the issue wasn’t due to my configuration changes. I also knew that a port can only be used by one application or daemon at a time so that clued me in that something else was already using the port. While I can’t give a definitive cause for the situation, I can give pointers on resolving the issue. Note that this pertains to Apache running on Linux so your mileage may vary.
Here’s what I encountered after I ran the ./apachectl start
command:
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:443
no listening sockets available, shutting down
Unable to open logs
To solve the issue I first tried the following to see if there were some running httpd processes that shouldn’t have been running at this point:
ps -aux |grep httpd
This revealed no processes running. Next I tried netstat
and that didn’t reveal anything either. Then I decide to view all processes with ps -aux, and after close inspection found the culprit:
root 5004 0.0 0.0 4384 4 ? S Apr25 0:00 bash
mysql 5095 0.0 0.7 41968 7980 ? S Apr25 0:47 ./mysqld --user mysql
apache 7323 0.0 0.0 3014368 0 ? TW Apr25 0:01
There was a phantom process (line 3 above) running as the apache user but didn’t have a command associated with it. Knowing that nothing else on the server runs as the apache user, I decided to kill the varmit:
kill -9 7323
After doing this, I was able to start the apache server again.
Has anyone else run into this issue and more importantly why it happened?