Apache: Could not bind address to port (make_sock)

If you’re upgrading server software, or changing your port config, you may accidentally Funk your Wagnalls. You’ll know the error when you try to restart apache.

~: sudo /etc/init.d/apache2 start
 * Starting web server apache2
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:8080
no listening sockets available, shutting down
Unable to open logs
   ...fail!

Apache is attempting to listen on port 8080, but cannot because it’s already in use. There are a few reasons why this might be happening.

Port configuration problem

If you have have duplicate entries, Apache will yell at you. Make sure that your apache.conf & ports.conf don’t both include this directive. If it’s only being listed once (see the example ports.conf below), then make sure you didn’t accidentally duplicate your ports.conf somewhere apache would notice.

Listen 8080

#<IfModule mod_ssl.c>
# Listen 443
#</IfModule>

Another service could be using the port

When I ran into this error, it was because another instance of apache was already running. This next example uses netstat, grep, and kill to root out & fix the problem.

# try to start apache, receive error

~: sudo /etc/init.d/apache2 start
 * Starting web server apache2
(98)Address already in use: make_sock: could not bind to address 0.0.0.0:8080
no listening sockets available, shutting down
Unable to open logs
   ...fail!

# see what's using the port (note that I'm searching for :80, I could also use :8080)

~: sudo netstat -tulpn| grep :80

tcp        0      0 0.0.0.0:8080            0.0.0.0:*               LISTEN      29004/apache2
tcp        0      0 0.0.0.0:80              0.0.0.0:*               LISTEN      28964/nginx

# I see that apache2 is using 8080! Kill it!

~: killall -9 apache2

# Let's try again, with success

~: sudo /etc/init.d/apache2 start
 * Starting web server apache2
   ...done.

Remember to dig in and evaluate server problems instead of just rebooting. I rebooted four times before I decided that I must have screwed something up.

Comments

Contact Us

We'd love to hear from you. Get in touch!

Boston

201 South Street, Boston, MA 02111

New York

315 Church St, New York, NY 10013

Phone & Email

(617)379-2752 hello@bocoup.com