Apache: Address already in use: make_sock: could not bind to address 0.0.0.0:80

Every now and then my Apache webserver becomes un-responsive, and attempting to restart it with apachectl graceful gives me the following error:

Address already in use: make_sock: could not bind to address 0.0.0.0:80

This error means that there is already a process running that is using port 80, so Apache is unable to start up and use it. To solve this problem, we need to figure out what process is currently using the port in question and kill it so that Apache can start. Use lsof to find out what is using our port:

shell> lsof -i :80
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
httpd 23506 apache 3u IPv6 1206927465 TCP *:http (LISTEN)

You can see from the output of lsof that an httpd process already exists under PID 23506. This is simple enough to get rid of:

shell> kill -9 23506
shell> lsof -i :80
shell> apachectl start

I run lsof again after issuing the kill command to make sure that whatever was using port 80 is gone.

2 responses to “Apache: Address already in use: make_sock: could not bind to address 0.0.0.0:80”

  1. Robert says:

    I’m getting the same error, however when I run the lsof command I don’t have anything running on port 80. Any ideas?I only started getting this error when I edited the /etc/apache2/httpd.conf file to have virtual hosts. If I comment the line “Listen 80” then it restarts, but the virtual hosts dont work.

  2. @Robert,
    Are you getting the error on port 80? Perhaps you are getting the error on port 443 instead? If so, run “lsof -i :443” and kill that one. You might have to run it for both :80 and :443 if you also have SSL configured.

    Also, do you have NameVirtualHost defined in httpd.conf?