Haproxy Bind Error

Commander Spock picture Commander Spock · Jul 28, 2013 · Viewed 11.5k times · Source

Hi there StackOverflow,

I seem to have an error with my haproxy, this is what I get when I try and run it

[ALERT] 208/051346 (5865) : Starting proxy ah1: cannot bind socket
[ALERT] 208/051346 (5865) : Starting proxy ah2: cannot bind socket

I'm running this for a TCP proxy.

This is my config:

#---------------------------------------------------------------------
# Example configuration for a possible web application.  See the
# full configuration options online.
#
#   http://haproxy.1wt.eu/download/1.3/doc/configuration.txt
#
#---------------------------------------------------------------------

#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
    global
    log         127.0.0.1 local2 
    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group       haproxy
    daemon

#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will 
# use if not designated in their block
#---------------------------------------------------------------------
defaults
    mode        tcp
    log         global
    option      dontlognull
    option      forwardfor
    option      redispatch
    timeout connect 10000 # default 10 second time out if a backend is not found
    timeout client 300000
    timeout server 300000
    maxconn     60000
    retries     3


listen ah1 207.254.9.41:30000
mode tcp
balance leastconn
server ah1_1 46.16.77.23:30000

listen ah2 207.254.9.41:30001
mode tcp
balance leastconn
server ah2_1 46.16.77.23:30001

We're running Red Hat Enterprise Linux 5 (x64)

Answer

dtorgo picture dtorgo · Aug 5, 2013

Check for already existing processes using ports 30000 and 30001:

lsof -i OR netstat -lnp

If you do not have anything listening on ports 30000 or 30001 then make sure that you have the ip address 207.254.9.41 actually configured on the system:

ip addr OR ifconfig

If you do not see 207.254.9.41 listed then you can either change it to the correct IP address or simply take the IP address off:

:30000 instead of 207.254.9.41:30000

If none of those fix it then I suggest upgrading to either 1.4 or 1.5 (I have been using 1.5 in a very large production environment for almost a year with no issues). If 1.4 and 1.5 are not in the package repositories then I suggest compiling yourself.