Fails to start haproxy

Here is my config file

listen minecraft
bind :25565
mode tcp
balance leastconn
option tcp-check
server minecraft1 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.

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.

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]

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?

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

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 and 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! :smiley: