Wednesday 7 March 2012

Apache: Could not bind address to port (make_sock)

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.

1:ps -e | grep httpd
21415 ? 00:00:00 httpd
21417 ? 00:00:00 httpd
21418 ? 00:00:00 httpd
21419 ? 00:00:00 httpd
21420 ? 00:00:00 httpd
21421 ? 00:00:00 httpd
21422 ? 00:00:00 httpd
21423 ? 00:00:00 httpd
21424 ? 00:00:00 httpd
21425 ? 00:00:00 httpd


[root@it ~]# kill 21415
[root@it ~]# kill 21415
-bash: kill: (21415) - No such process
[root@it ~]# ps -e | grep httpd
[root@it ~]# service httpd restart
Stopping httpd: [FAILED]
Starting httpd: [ OK ]



2:- ~: 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 Listen 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

#
# Listen 443
#

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.

1 comment:

  1. I have tried many time but still the issues persist, is there any way to get resolve the issues.

    Port 80 listen only httpd.

    ReplyDelete