haproxy - cannot bind socket error - ubuntu 20.04
NickName:Krishna Ask DateTime:2021-10-04T16:36:41

haproxy - cannot bind socket error - ubuntu 20.04

I followed the instructions here https://kifarunix.com/install-and-setup-haproxy-on-ubuntu-20-04/ & have almost set up HTTPS. The function beam.smp which is specific to couchdb was bound to 5984 & hence not allowing haproxy to start.

Error log from terminal:

Oct 04 08:11:58 AgentDost systemd[1]: haproxy.service: Scheduled restart job, restart counter is at 4.
Oct 04 08:11:58 AgentDost systemd[1]: Stopped HAProxy Load Balancer.
Oct 04 08:11:58 AgentDost systemd[1]: Starting HAProxy Load Balancer...
Oct 04 08:11:59 AgentDost haproxy[31476]: [ALERT] 276/081158 (31476) : Starting frontend couch.tezi.app: cannot bind socket [174.138.120.68:5984]
Oct 04 08:11:59 AgentDost haproxy[31476]: Proxy webapps started.
Oct 04 08:11:59 AgentDost haproxy[31476]: Proxy webapps started.
Oct 04 08:11:59 AgentDost haproxy[31476]: [ALERT] 276/081158 (31476) : Starting proxy stats: cannot bind socket [174.138.120.68:5984]
Oct 04 08:11:59 AgentDost systemd[1]: haproxy.service: Main process exited, code=exited, status=1/FAILURE
Oct 04 08:11:59 AgentDost systemd[1]: haproxy.service: Failed with result 'exit-code'.
Oct 04 08:11:59 AgentDost systemd[1]: Failed to start HAProxy Load Balancer.

So I stopped the service to be able to bind the haproxy service to the port. Now beam.smp is not bound to the port but still haproxy is not able to takeover. What could be the reason here?

Oct 04 08:11:58 AgentDost systemd[1]: haproxy.service: Scheduled restart job, restart counter is at 4.
Oct 04 08:11:58 AgentDost systemd[1]: Stopped HAProxy Load Balancer.
Oct 04 08:11:58 AgentDost systemd[1]: Starting HAProxy Load Balancer...
Oct 04 08:11:59 AgentDost haproxy[31476]: [ALERT] 276/081158 (31476) : Starting frontend couch.tezi.app: cannot bind socket [174.138.120.68:5984]
Oct 04 08:11:59 AgentDost haproxy[31476]: Proxy webapps started.
Oct 04 08:11:59 AgentDost haproxy[31476]: Proxy webapps started.
Oct 04 08:11:59 AgentDost haproxy[31476]: [ALERT] 276/081158 (31476) : Starting proxy stats: cannot bind socket [174.138.120.68:5984]
Oct 04 08:11:59 AgentDost systemd[1]: haproxy.service: Main process exited, code=exited, status=1/FAILURE
Oct 04 08:11:59 AgentDost systemd[1]: haproxy.service: Failed with result 'exit-code'.
Oct 04 08:11:59 AgentDost systemd[1]: Failed to start HAProxy Load Balancer.
Oct 04 08:11:59 AgentDost systemd[1]: haproxy.service: Scheduled restart job, restart counter is at 5.
Oct 04 08:11:59 AgentDost systemd[1]: Stopped HAProxy Load Balancer.
Oct 04 08:11:59 AgentDost systemd[1]: haproxy.service: Start request repeated too quickly.
Oct 04 08:11:59 AgentDost systemd[1]: haproxy.service: Failed with result 'exit-code'.
Oct 04 08:11:59 AgentDost systemd[1]: Failed to start HAProxy Load Balancer.
root@AgentDost:~# sudo ss -4 -tlnp | grep 80
LISTEN    0         511                0.0.0.0:80               0.0.0.0:*        users:(("nginx",pid=751,fd=6),("nginx",pid=750,fd=6))                          
root@AgentDost:~# ss -4 -tlnp | grep 5984

I tried changing the frontend to port 6984 but even that doesn't help.

Error log from terminal:

Oct 04 08:21:26 AgentDost systemd[1]: haproxy.service: Scheduled restart job, restart counter is at 4.
Oct 04 08:21:26 AgentDost systemd[1]: Stopped HAProxy Load Balancer.
Oct 04 08:21:26 AgentDost systemd[1]: Starting HAProxy Load Balancer...
Oct 04 08:21:27 AgentDost haproxy[31747]: [ALERT] 276/082126 (31747) : Starting frontend couch.tezi.app: cannot bind socket [174.138.120.68:6984]
Oct 04 08:21:27 AgentDost haproxy[31747]: Proxy webapps started.
Oct 04 08:21:27 AgentDost haproxy[31747]: Proxy webapps started.
Oct 04 08:21:27 AgentDost haproxy[31747]: [ALERT] 276/082126 (31747) : Starting proxy stats: cannot bind socket [174.138.120.68:5984]
Oct 04 08:21:27 AgentDost systemd[1]: haproxy.service: Main process exited, code=exited, status=1/FAILURE
Oct 04 08:21:27 AgentDost systemd[1]: haproxy.service: Failed with result 'exit-code'.
Oct 04 08:21:27 AgentDost systemd[1]: Failed to start HAProxy Load Balancer.
Oct 04 08:21:27 AgentDost systemd[1]: haproxy.service: Scheduled restart job, restart counter is at 5.
Oct 04 08:21:27 AgentDost systemd[1]: Stopped HAProxy Load Balancer.
Oct 04 08:21:27 AgentDost systemd[1]: haproxy.service: Start request repeated too quickly.
Oct 04 08:21:27 AgentDost systemd[1]: haproxy.service: Failed with result 'exit-code'.
Oct 04 08:21:27 AgentDost systemd[1]: Failed to start HAProxy Load Balancer.
root@AgentDost:~# ss -4 -tlnp | grep 6984
root@AgentDost:~# ss -4 -tlnp | grep 5984
LISTEN    0         128                0.0.0.0:5984             0.0.0.0:*        users:(("beam.smp",pid=31658,fd=16))     

Copyright Notice:Content Author:「Krishna」,Reproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/69433131/haproxy-cannot-bind-socket-error-ubuntu-20-04

More about “haproxy - cannot bind socket error - ubuntu 20.04” related questions

haproxy - cannot bind socket error - ubuntu 20.04

I followed the instructions here https://kifarunix.com/install-and-setup-haproxy-on-ubuntu-20-04/ & have almost set up HTTPS. The function beam.smp which is specific to couchdb was bound to 598...

Show Detail

HAProxy cannot bind socket 80 or 443 - Ubuntu

Just to preface this question - I have attempted all other solutions I found via search on here. All of those were suggesting to check if other services are bound to the ports but in my case there ...

Show Detail

Haproxy SSL on Ubuntu 20.04

im trying to configure SSL on HAproxy in Ubuntu 20.04. I have Windows machine as CA, now I have a problem with making a certificate file. I've searched internet but saw many solutions in creating PEM

Show Detail

HAProxy for postgresql Load Balancer start error - cannot bind socket

I am setting postgresql loadbalance using Haproxy and I met a error messages as below: Jun 30 07:57:43 vm0 systemd[1]: Starting HAProxy Load Balancer... Jun 30 07:57:43 vm0 haproxy[15084]: [ALERT] ...

Show Detail

HAProxy cannot bind to socket 1883

I am trying to bind a HaProxy on a Fedora 21 instance to socket 1883 (for the MQTT protocol). I get [ALERT] 215/130943 (926) : Starting proxy mqtt: cannot bind socket [0.0.0.0:1883] There does ...

Show Detail

Cannot bind socket [0.0.0.0:443] for HAproxy

I have made the following ha-proxy configuration and have recieved the following error while HAProxy restart: HAproxy Config global log /dev/log local0 log /dev/log local1 n...

Show Detail

start haproxy without Sudo: Starting frontend http-in: cannot bind socket

If I did execute haproxy from User with Sudoers right (Oracle Linux 7.5) /data/haproxy/haproxy -f /etc/haproxy/haproxy.cfg did start OK. If I use User without Sudoers rights did return error: St...

Show Detail

HaProxy (cannot bind socket, select test failed)

Hello everyone, Im working about an high availbility project, I had to put in production an haproxy for some applications. Everything was ok after some basics tests but I had some errors and cant ...

Show Detail

Volume mount haproxy socket from HAProxy docker container

I want to give a peer container access to /var/run/haproxy.sock. Unfortunately, it throws an error when I try to do this through bind mounting with a named volume. Is is possible to share the haproxy.

Show Detail

Cannot restart haproxy

I am trying to restart haproxy, when I type haproxy -f /etc/haproxy/haproxy.cfg I get the following error: [ALERT] 212/124840 (9060) : Starting proxy mysql-cluster: cannot bind socket I...

Show Detail