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

This is a post for those sysadmins out there who run into problems running servers with a LAMP setup. This issue will crop up occasionally in AWS Linux, on EC2 instances, but its a common error on Linux systems running apache as a web server.

Occasionally, for some reason or another – usually because you changed some setting – it is necessary to restart apache from the terminal (i.e. in PuTTy).

Sometimes, though this is rare, this fails. If apache fails to restart and displays a message similar to “Address already in use: make_sock: could not bind to address” then you may be wondering how to get your server back online!

The precise message you receive could look something like this:

Starting httpd: (98)Address already in use: make_sock: could not bind to address                                 [::]:80

(98)Address already in use: make_sock: could not bind to address 0.0.0.0:80
no listening sockets available, shutting down
Unable to open logs

You may or may not have other error messages, but let’s deal with this one!

The slow fix is to do a full hardware reboot of your server. This takes quite some time, and is not necessarily the best course of action, but it should solve this issue.

The reason for the message, however, is that there are still active connections which were not closed before. Probably some process was running when you hit “restart” (you should identify just what by checking – but that’s beyond the scope of what we’re doing here!). In any case, you’ll want to find out what process is running, and “kill” it.

Here’s how:

1) Type “ps -aux |grep httpd

2) This will return a set of processes which are currently running. There should not be more than one or two. It will look something like this:

root     23605  0.1  0.1 861052 21208 ?        Ss   10:07   0:00 /usr/sbin/httpd
apache   23609  0.0  0.0 220500  7720 ?        S    10:07   0:00 /usr/sbin/httpd
root     23697  0.0  0.0  61184   776 pts/0    S+   10:10   0:00 grep httpd

3) Kill the apache processes which are showing by typing:

kill -9 23609

Remember to replace “23609” with whatever number your process actually is!

An alternative to this, if you have a lot of processes all running, is to use the “killall” method, which is:

killall -9 httpd

Then restart apache – it should work correctly!

You’ll then want to set about identifying which processes were causing this in the first place!

Leave a comment below if this worked for you – or if it didn’t – and we might be able to help.

3 thoughts on “Apache HTTPD: Address already in use: make_sock: could not bind to address”

  1. I have tried the same way more then 10 times but its getting the same issues.

    Anybody given the solution for that.

    We have installed ZendServer.

    when i restart the apachect1 restart

    showing the below error.

    ————-
    (99)Cannot assign requested address: make_sock: could not bind to address 0.0.0.0:80
    no listening sockets available, shutting down
    Unable to open logs
    ———-

    Reply
    • Hi,

      You may need to be logged in as root, or, if you cannot login as root, you should type “sudo ” at the start of your command (or, simply, when you first login, type “sudo -i” and hit return…

      This might help!

      Reply

Leave a Reply to Magesh M Cancel reply

No links of any kind allowed in comments - if you add any links, your comment will automatically be deleted.