# Fails to start haproxy

**URL:** <https://discourse.haproxy.org/t/fails-to-start-haproxy/3881>\
**Category:** Help!\
**Created:** [June 1, 2019, 3:48pm UTC](https://discourse.haproxy.org/t/fails-to-start-haproxy/3881 "2019-06-01T15:48:03Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SunnyLo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/sunnylo/32/843_2.png) [@SunnyLo](https://discourse.haproxy.org/u/SunnyLo)\
**Post date:** [June 1, 2019, 3:48pm UTC](https://discourse.haproxy.org/t/fails-to-start-haproxy/3881/1 "2019-06-01T15:48:03Z")

</div>

Here is my config file

listen minecraft  
bind :25565  
mode tcp  
balance leastconn  
option tcp-check  
server minecraft1 [example.com:25570](http://example.com:25570) send-proxy

But it fails to start with this error

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 Sat 2019-06-01 23:43:48 HKT; 5s ago

Docs: man:haproxy(1)

file:/usr/share/doc/haproxy/configuration.txt.gz

Process: 3190 ExecStart=/usr/sbin/haproxy -Ws -f $CONFIG -p $PIDFILE $EXTRAOPTS **(code=exited, status=1/FAILURE)**

Process: 3183 ExecStartPre=/usr/sbin/haproxy -f $CONFIG -c -q $EXTRAOPTS (code=exited, status=0/SUCCESS)

Main PID: 3190 (code=exited, status=1/FAILURE)

Jun 01 23:43:48 vps1 systemd[1]: **haproxy.service: Main process exited, code=exited, status=1/FAILURE**

Jun 01 23:43:48 vps1 systemd[1]: **haproxy.service: Failed with result ‘exit-code’.**

Jun 01 23:43:48 vps1 systemd[1]: **Failed to start HAProxy Load Balancer.**

Jun 01 23:43:48 vps1 systemd[1]: haproxy.service: Service hold-off time over, scheduling restart.

Jun 01 23:43:48 vps1 systemd[1]: haproxy.service: Scheduled restart job, restart counter is at 5.

Jun 01 23:43:48 vps1 systemd[1]: Stopped HAProxy Load Balancer.

Jun 01 23:43:48 vps1 systemd[1]: **haproxy.service: Start request repeated too quickly.**

Jun 01 23:43:48 vps1 systemd[1]: **haproxy.service: Failed with result ‘exit-code’.**

Jun 01 23:43:48 vps1 systemd[1]: **Failed to start HAProxy Load Balancer.**

---

<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, 2019, 8:05pm UTC](https://discourse.haproxy.org/t/fails-to-start-haproxy/3881/2 "2019-06-01T20:05:46Z")

</div>

Check your configuration with `haproxy -c -f /path/to/haproxy.cfg` and try to start it manually (in foreground, to test) with `haproxy -db -f /path/to/haproxy.cfg`.

---

<div class="post-metadata">

**Author:** ![SunnyLo](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/sunnylo/32/843_2.png) [@SunnyLo](https://discourse.haproxy.org/u/SunnyLo)\
**Post date:** [June 1, 2019, 10:19pm UTC](https://discourse.haproxy.org/t/fails-to-start-haproxy/3881/3 "2019-06-01T22:19:18Z")

</div>

Even if it said the configuration is valid. It still cannot start

I got `[ALERT] 152/061730 (2610) : Starting proxy minecraft: cannot bind socket [0.0.0.0:25570]`

---

<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 2, 2019, 8:24pm UTC](https://discourse.haproxy.org/t/fails-to-start-haproxy/3881/4 "2019-06-02T20:24:07Z")

</div>

Right, the configuration is valid.

You just posted the reason for the failure here:

Haproxy cannot bind to socket `25570`, which you don’t try to bind to, according the configuration in the first post. So the configuration provided is not what you are actually trying to start.

Do you want haproxy to listen to `25570` or `25565`?

---

<div class="post-metadata">

**Author:** ![AeSix](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/aesix/32/666_2.png) [@AeSix](https://discourse.haproxy.org/u/AeSix)\
**Post date:** [June 7, 2019, 12:25pm UTC](https://discourse.haproxy.org/t/fails-to-start-haproxy/3881/5 "2019-06-07T12:25:52Z")

</div>

Hi!  
So, I wrote a post regarding using HAProxy with Minecraft. You can find it here:

> **[obscure corner for obscure conf file...](https://www.spigotmc.org/threads/obscure-corner-for-obscure-conf-file.345414/#post-3212938)**
>
> Do what you will with this. I've tried to explain everything simply. Credit goes to Prplz for giving me the offset needed, and pointing out that \<=1.8...

You’ll need HAProxy to listen to port 25565, _IF_ you want your players to **not** have to type in a port number to connect. You will then need to ensure, a) 25565 is not blocked by any firewall, including iptables/ufw as well as any upstream hardware firewall, and b) that your bungeecord/spigot/paper/forege servers are NOT using 25565 for connections. You can use 25565 for query however, as it uses UDP, and HAProxy does not interfere with UDP.

If you’re using DNS SRV records, then it don’t matter what port you’re having HAProxy listen to, as long as it’s not firewalled AND matches the port in the SRV record. Otherwise, if you don’t care if players have to type a port numer (You _SHOULD_ care)… yeah…

Anyways, the config on my spigot post has some hints as to what each section is doing, so you can play with them a bit. It’s not a simplified config, but it’s a basic one. It’s also doing routing based on original destination address, so you can have [play.example.com](http://play.example.com) and [test.example.com](http://test.example.com) point to two different servers, both using the same port (since HAProxy is listening to the port)

Anyways, enjoy and I hope this helps more than it hurts! 😃
