# Failed to start HAProxy Load Balancer

**URL:** <https://discourse.haproxy.org/t/failed-to-start-haproxy-load-balancer/5224>\
**Category:** Help!\
**Created:** [May 14, 2020, 11:04am UTC](https://discourse.haproxy.org/t/failed-to-start-haproxy-load-balancer/5224 "2020-05-14T11:04:38Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![AneeshBabu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/aneeshbabu/32/1170_2.png) [@AneeshBabu](https://discourse.haproxy.org/u/AneeshBabu)\
**Post date:** [May 14, 2020, 11:04am UTC](https://discourse.haproxy.org/t/failed-to-start-haproxy-load-balancer/5224/1 "2020-05-14T11:04:38Z")

</div>

root@Test-QA:/etc/haproxy# **service haproxy start**  
Job for haproxy.service failed because the control process exited with error code.  
See “systemctl status haproxy.service” and “journalctl -xe” for details.

root@Test-QA:/etc/haproxy# **systemctl status haproxy.service**  
● haproxy.service - HAProxy Load Balancer  
Loaded: loaded (/lib/systemd/system/haproxy.service; enabled; vendor preset: enabled)  
Active: failed (Result: exit-code) since Thu 2020-05-14 16:18:01 IST; 9min ago  
Docs: man:haproxy(1)  
file:/usr/share/doc/haproxy/configuration.txt.gz  
Process: 8564 ExecStart=/usr/sbin/haproxy -Ws -f $CONFIG -p $PIDFILE $EXTRAOPTS **(code=exited, status=1/FAILURE)**  
Process: 8553 ExecStartPre=/usr/sbin/haproxy -f $CONFIG -c -q $EXTRAOPTS (code=exited, status=0/SUCCESS)  
**Main PID: 8564 (code=exited, status=1/FAILURE)**

May 14 16:18:01 Test-QA systemd[1]: haproxy.service: Service hold-off time over, scheduling restart.  
May 14 16:18:01 Test-QA systemd[1]: haproxy.service: Scheduled restart job, restart counter is at 5.  
May 14 16:18:01 Test-QA systemd[1]: Stopped HAProxy Load Balancer.  
May 14 16:18:01 Test-QA systemd[1]: haproxy.service: Start request repeated too quickly.  
May 14 16:18:01 Test-QA systemd[1]: haproxy.service: Failed with result ‘exit-code’.  
May 14 16:18:01 Test-QA systemd[1]: **Failed to start HAProxy Load Balancer.**

---

<div class="post-metadata">

**Author:** ![AneeshBabu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/aneeshbabu/32/1170_2.png) [@AneeshBabu](https://discourse.haproxy.org/u/AneeshBabu)\
**Post date:** [May 20, 2020, 12:34pm UTC](https://discourse.haproxy.org/t/failed-to-start-haproxy-load-balancer/5224/2 "2020-05-20T12:34:58Z")

</div>

Hi @lukastribus

# Configuring MySQL load balancing

when executed the below command ,facing the **ERROR**

```
root@Test-QA:~# service haproxy start
Job for haproxy.service failed because the control process exited with error code.
See "systemctl status haproxy.service" and "journalctl -xe" for details.

root@Test-QA:~# systemctl status haproxy.service
● haproxy.service - HAProxy Load Balancer
   Loaded: loaded (/lib/systemd/system/haproxy.service; enabled; vendor preset: enabled)
   Active: failed (Result: exit-code) since Wed 2020-05-20 17:48:34 IST; 4s ago
     Docs: man:haproxy(1)
           file:/usr/share/doc/haproxy/configuration.txt.gz
  Process: 14477 ExecStartPre=/usr/sbin/haproxy -f $CONFIG -c -q $EXTRAOPTS (code=exited, status=1/FAILURE)

May 20 17:48:33 Test-QA systemd[1]: haproxy.service: Control process exited, code=exited status=1
May 20 17:48:33 Test-QA systemd[1]: haproxy.service: Failed with result 'exit-code'.
May 20 17:48:33 Test-QA systemd[1]: Failed to start HAProxy Load Balancer.
May 20 17:48:34 Test-QA systemd[1]: haproxy.service: Service hold-off time over, scheduling restart.
May 20 17:48:34 Test-QA systemd[1]: haproxy.service: Scheduled restart job, restart counter is at 5.
May 20 17:48:34 Test-QA systemd[1]: Stopped HAProxy Load Balancer.
May 20 17:48:34 Test-QA systemd[1]: haproxy.service: Start request repeated too quickly.
May 20 17:48:34 Test-QA systemd[1]: haproxy.service: Failed with result 'exit-code'.
May 20 17:48:34 Test-QA systemd[1]: Failed to start HAProxy Load Balancer.

```

# Below is my Config file …

```
global
    log 127.0.0.0 local0 notice
    maxconn 150
    chroot /var/lib/haproxy
    stats socket /run/haproxy/admin.sock mode 660 level admin
    stats timeout 30s
    user haproxy
    group haproxy

defaults
    log global
    retries 2
    mode tcp
    option httplog
    timeout connect 4s
    timeout server 30m
    timeout client 30m
    timeout check 5s

listen mysql-cluster
    bind 127.0.0.0:3306
    mode tcp
    option mysql-check user haproxy_check
    balance roundrobin
    server Test-QA 10.0.0.1:3306 check
    server Stage-QA 10.0.0.2:3306 check
```

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [May 20, 2020, 8:48pm UTC](https://discourse.haproxy.org/t/failed-to-start-haproxy-load-balancer/5224/3 "2020-05-20T20:48:00Z")

</div>

Start manually as root and in foreground and check the error message:

```
$ haproxy -f /path/to/haproxyconfig -db
```

---

<div class="post-metadata">

**Author:** ![AneeshBabu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/aneeshbabu/32/1170_2.png) [@AneeshBabu](https://discourse.haproxy.org/u/AneeshBabu)\
**Post date:** [May 21, 2020, 5:47am UTC](https://discourse.haproxy.org/t/failed-to-start-haproxy-load-balancer/5224/4 "2020-05-21T05:47:26Z")

</div>

**Executed the command …:**

```
root@Test-QA:/etc/haproxy# haproxy -f /path/TO/haproxyconfig -db
[ALERT] 141/111636 (12567) : Cannot open configuration file/directory /path/TO/haproxyconfig : No such file or directory
```

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [May 21, 2020, 6:57am UTC](https://discourse.haproxy.org/t/failed-to-start-haproxy-load-balancer/5224/5 "2020-05-21T06:57:51Z")

</div>

`/path/to/haproxyconfig` was supposed to be an example, you should replace it with the actual path to your haproxy configuration file.

---

<div class="post-metadata">

**Author:** ![AneeshBabu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/aneeshbabu/32/1170_2.png) [@AneeshBabu](https://discourse.haproxy.org/u/AneeshBabu)\
**Post date:** [May 21, 2020, 7:34am UTC](https://discourse.haproxy.org/t/failed-to-start-haproxy-load-balancer/5224/6 "2020-05-21T07:34:53Z")

</div>

@lukastribus  
**Executed this command =\>haproxy -f /etc/haproxy/haproxy.cfg -db**

```
root@Test-QA:/etc/haproxy# haproxy -f /etc/haproxy/haproxy.cfg -db
[ALERT] 141/130238 (22117) : parsing [/etc/haproxy/haproxy.cfg:5] : log : invalid address: '127.0.0.0.' in '127.0.0.0.'

[ALERT] 141/130238 (22117) : parsing [/etc/haproxy/haproxy.cfg:25] : 'bind' : invalid address: '127.0.0.0.' in '127.0.0.0.:3306'
[ALERT] 141/130238 (22117) : Error(s) found in configuration file : /etc/haproxy/haproxy.cfg
[ALERT] 141/130238 (22117) : Fatal errors found in configuration.
```

---

<div class="post-metadata">

**Author:** ![AneeshBabu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/aneeshbabu/32/1170_2.png) [@AneeshBabu](https://discourse.haproxy.org/u/AneeshBabu)\
**Post date:** [May 21, 2020, 7:49am UTC](https://discourse.haproxy.org/t/failed-to-start-haproxy-load-balancer/5224/7 "2020-05-21T07:49:37Z")

</div>

@lukastribus  
**Now getting this ERROR …when executed =\> haproxy -f /etc/haproxy/haproxy.cfg -d**

```
root@Test-QA:/etc/haproxy# haproxy -f /etc/haproxy/haproxy.cfg -d
[WARNING] 141/131611 (23532) : parsing [/etc/haproxy/haproxy.cfg:17] : 'option httplog' not usable with proxy 'mysql-cluster' (needs 'mode http'). Falling back to 'option tcplog'.
Available polling systems :
      epoll : pref=300, test result OK
       poll : pref=200, test result OK
     select : pref=150, test result OK
Total: 3 (3 usable), will use epoll.

Available filters :
        [SPOE] spoe
        [CACHE] cache
        [FCGI] fcgi-app
        [TRACE] trace
        [COMP] compression
Using epoll() as the polling mechanism.
[ALERT] 141/131611 (23532) : Starting proxy mysql-cluster: cannot bind socket [127.0.0.0:3306]
```

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [May 21, 2020, 8:57am UTC](https://discourse.haproxy.org/t/failed-to-start-haproxy-load-balancer/5224/8 "2020-05-21T08:57:06Z")

</div>

Your system is refusing to let you bind to 127.0.0.0, maybe you need to use 127.0.0.1 instead.

What’s your OS/kernel?

---

<div class="post-metadata">

**Author:** ![AneeshBabu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/aneeshbabu/32/1170_2.png) [@AneeshBabu](https://discourse.haproxy.org/u/AneeshBabu)\
**Post date:** [May 21, 2020, 8:58am UTC](https://discourse.haproxy.org/t/failed-to-start-haproxy-load-balancer/5224/9 "2020-05-21T08:58:24Z")

</div>

ubuntu 18 LTS

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [May 21, 2020, 11:38am UTC](https://discourse.haproxy.org/t/failed-to-start-haproxy-load-balancer/5224/10 "2020-05-21T11:38:50Z")

</div>

Did you try with `127.0.0.1` ?

---

<div class="post-metadata">

**Author:** ![AneeshBabu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/aneeshbabu/32/1170_2.png) [@AneeshBabu](https://discourse.haproxy.org/u/AneeshBabu)\
**Post date:** [May 21, 2020, 11:41am UTC](https://discourse.haproxy.org/t/failed-to-start-haproxy-load-balancer/5224/11 "2020-05-21T11:41:56Z")

</div>

127.0.0.0 is working …

getting new error …

```
root@Test-QA:/etc/haproxy# service haproxy status
● haproxy.service - HAProxy Load Balancer
   Loaded: loaded (/lib/systemd/system/haproxy.service; enabled; vendor preset: enabled)
   Active: active (running) since Thu 2020-05-21 16:53:37 IST; 16min ago
     Docs: man:haproxy(1)
           file:/usr/share/doc/haproxy/configuration.txt.gz
  Process: 4787 ExecStartPre=/usr/sbin/haproxy -f $CONFIG -c -q $EXTRAOPTS (code=exited, status=0/SUCCESS)
 Main PID: 4796 (haproxy)
    Tasks: 3 (limit: 4915)
   CGroup: /system.slice/haproxy.service
           ├─4796 /usr/sbin/haproxy -Ws -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -S /run/haproxy-master.sock
           └─4799 /usr/sbin/haproxy -Ws -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -S /run/haproxy-master.sock

May 21 16:53:37 Test-QA systemd[1]: Starting HAProxy Load Balancer...
May 21 16:53:37 Test-QA haproxy[4796]: [NOTICE] 141/165337 (4796) : New worker #1 (4799) forked
May 21 16:53:37 Test-QA systemd[1]: Started HAProxy Load Balancer.
May 21 16:53:39 Test-QA haproxy[4796]: [WARNING] 141/165339 (4799) : Server mysql-cluster/Test-QA is DOWN, reason: Layer4 timeout, check duration: 2000ms. 1 active and 0
May 21 16:53:40 Test-QA haproxy[4796]: [WARNING] 141/165340 (4799) : Server mysql-cluster/Stage-QA is DOWN, reason: Layer4 timeout, check duration: 2002ms. 0 active a
May 21 16:53:40 Test-QA haproxy[4796]: [ALERT] 141/165340 (4799) : proxy 'mysql-cluster' has no server available!
```

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [May 21, 2020, 12:46pm UTC](https://discourse.haproxy.org/t/failed-to-start-haproxy-load-balancer/5224/12 "2020-05-21T12:46:53Z")

</div>

I assume mysql is actually reachable from haproxy?

You probably need to add the `post-41` keyword to the health checks:

[https://cbonte.github.io/haproxy-dconv/2.0/configuration.html#4-option%20mysql-check](https://cbonte.github.io/haproxy-dconv/2.0/configuration.html#4-option%20mysql-check)

---

<div class="post-metadata">

**Author:** ![AneeshBabu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/aneeshbabu/32/1170_2.png) [@AneeshBabu](https://discourse.haproxy.org/u/AneeshBabu)\
**Post date:** [May 21, 2020, 1:27pm UTC](https://discourse.haproxy.org/t/failed-to-start-haproxy-load-balancer/5224/13 "2020-05-21T13:27:44Z")

</div>

@lukastribus

**For your information …:**  
I have 2 servers CONFIGURED MySQL Master-Master Replication and

# HAPROXY installed in server Test-QA 10.0.0.1

```
  1) server Test-QA 10.0.0.1 port 3306
  2) server Stage-QA 10.0.0.2 port 3306

```

 ![Haproxy-arch](https://us1.discourse-cdn.com/flex016/uploads/haproxy/original/2X/2/2b2f7cb2defe570debca695f78920976ba54be43.jpeg)

**Please review the config file below …:**  
i have added `post-41` in my config file …

```
global
    log 127.0.0.0 local0
    log 127.0.0.0 local0 notice
    maxconn 150
    chroot /var/lib/haproxy
    stats socket /run/haproxy/admin.sock mode 660 level admin
    stats timeout 30s
    user haproxy
    group haproxy
    daemon

defaults
    log global
    retries 3
    timeout connect 4s
    timeout server 30m
    timeout client 30m
    timeout check 5s

# MySQL Load Balance Pool
listen mysql-cluster
    bind :3306
    mode tcp
    option mysql-check user haproxy_check post-41
    balance roundrobin
    server Test-QA 10.0.0.1:3306 check
    server Stage-QA 10.0.0.2:3306 check
```

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [May 21, 2020, 1:52pm UTC](https://discourse.haproxy.org/t/failed-to-start-haproxy-load-balancer/5224/14 "2020-05-21T13:52:06Z")

</div>

Looks fine to me.

---

<div class="post-metadata">

**Author:** ![AneeshBabu](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/aneeshbabu/32/1170_2.png) [@AneeshBabu](https://discourse.haproxy.org/u/AneeshBabu)\
**Post date:** [May 28, 2020, 5:13pm UTC](https://discourse.haproxy.org/t/failed-to-start-haproxy-load-balancer/5224/15 "2020-05-28T17:13:19Z")

</div>

Hi @lukastribus  
Could you please check the highlighted text below…what could be the problem…?

> root@Test-QA:/etc/haproxy# **service haproxy status**  
> ● haproxy.service - HAProxy Load Balancer  
> Loaded: loaded (/lib/systemd/system/haproxy.service; enabled; vendor preset: enabled)  
> Active: active (running) since Thu 2020-05-28 22:33:55 IST; 3min 32s ago  
> Docs: man:haproxy(1)  
> file:/usr/share/doc/haproxy/configuration.txt.gz  
> Process: 7246 ExecStartPre=/usr/sbin/haproxy -f $CONFIG -c -q $EXTRAOPTS (code=exited, status=0/SUCCESS)  
> Main PID: 7256 (haproxy)  
> Tasks: 3 (limit: 4915)  
> CGroup: /system.slice/haproxy.service  
> ├─7256 /usr/sbin/haproxy -Ws -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -S /run/haproxy-master.sock  
> └─7262 /usr/sbin/haproxy -Ws -f /etc/haproxy/haproxy.cfg -p /run/haproxy.pid -S /run/haproxy-master.sock
> 
> May 28 22:33:55 Test-QA systemd[1]: Starting HAProxy Load Balancer…  
> **May 28 22:33:55 Test-QA haproxy[7256]: [ALERT] 148/223355 (7256) : sendmsg()/writev() failed in logger #1: Permission denied (errno=13)**  
> **May 28 22:33:55 Test-QA haproxy[7256]: [NOTICE] 148/223355 (7256) : New worker #1 (7262) forked**  
> **May 28 22:33:55 Test-QA systemd[1]: Started HAProxy Load Balancer.**  
> **May 28 22:33:57 Test-QA haproxy[7256]: [WARNING] 148/223357 (7262) : Server mysql-cluster/Test-QA is DOWN, reason: Layer4 timeout, check duration: 2001ms. 1 active and 0**  
> **May 28 22:33:58 Test-QA haproxy[7256]: [WARNING] 148/223358 (7262) : Server mysql-cluster/irl-dev-pr-proxysql is DOWN, reason: Layer4 timeout, check duration: 2002ms. 0 active a**  
> **May 28 22:33:58 Test-QA haproxy[7256]: [ALERT] 148/223358 (7262) : proxy ‘mysql-cluster’ has no server available!**

---

<div class="post-metadata">

**Author:** ![lukastribus](https://avatars.discourse-cdn.com/v4/letter/l/7ea924/32.png) [@lukastribus](https://discourse.haproxy.org/u/lukastribus)\
**Post date:** [June 1, 2020, 11:10am UTC](https://discourse.haproxy.org/t/failed-to-start-haproxy-load-balancer/5224/16 "2020-06-01T11:10:03Z")

</div>

> [@AneeshBabu](#):
>
> **May 28 22:33:55 Test-QA haproxy[7256]: [ALERT] 148/223355 (7256) : sendmsg()/writev() failed in logger #1: Permission denied (errno=13)**

Your OS again refuses to work with the IP `127.0.0.0`. Please remove it all including the logging configuration and make sure logging actually works properly.

> [@AneeshBabu](#):
>
> Server mysql-cluster/Test-QA is DOWN, reason: Layer4 timeout, check duration: 2001ms. 1 active and 0

Your mysql backends are not reachable at `10.0.0.1:3306` and `10.0.0.2:3306` at layer4. Check that those services are actually listening and available on the IP:port set you configured in haproxy.

---

<div class="post-metadata">

**Author:** ![RicarHincapie](https://avatars.discourse-cdn.com/v4/letter/r/ee59a6/32.png) [@RicarHincapie](https://discourse.haproxy.org/u/RicarHincapie)\
**Post date:** [November 10, 2021, 3:17pm UTC](https://discourse.haproxy.org/t/failed-to-start-haproxy-load-balancer/5224/17 "2021-11-10T15:17:00Z")

</div>

This worked perfect for me. I had a missing ssl certificate and HAProxy would not start if it does not find it.  
Thanks!
