# Haproxy loses connections

**URL:** <https://discourse.haproxy.org/t/haproxy-loses-connections/2061>\
**Category:** Help!\
**Created:** [February 1, 2018, 12:06pm UTC](https://discourse.haproxy.org/t/haproxy-loses-connections/2061 "2018-02-01T12:06:36Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrquokka](https://avatars.discourse-cdn.com/v4/letter/m/4af34b/32.png) [@mrquokka](https://discourse.haproxy.org/u/mrquokka)\
**Post date:** [February 1, 2018, 12:06pm UTC](https://discourse.haproxy.org/t/haproxy-loses-connections/2061/1 "2018-02-01T12:06:36Z")

</div>

When i connect to haproxy balancer and try execute every queries psql tell me:  
server closed the connection unexpectedly  
This probably means the server terminated abnormally  
before or while processing the request.  
The connection to the server was lost. Attempting reset: Succeeded.  
I repeat this command and now it works, but why?  
When i use them direct on current base it works without errors, and reserve server got it

My configuration:  
Main server: 192.168.8.201  
keepalived for 192.168.8.210  
haproxy  
patroni  
etcd  
postgresql look for \*:5432

Fail-over server: 192.168.8.202  
keepalived for 192.168.8.210  
haproxy  
patroni  
etcd(deep copy of previous, because onlye 2 machines, without changes on future)  
postgresql look \*:5432

Haproxy config:

global  
maxconn 100  
defaults  
log global  
mode tcp  
retries 2  
timeout client 4s  
timeout connect 4s  
timeout server 4s  
timeout check 5s  
listen stats  
mode http  
bind \*:7000  
stats enable  
stats uri /  
listen batman  
bind \*:5000  
option httpchk  
http-check expect status 200  
default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions  
server postgresql\_0 192.168.8.201:5432 maxconn 100 check port 8008  
server postgresql\_1 192.168.8.202:5433 maxconn 100 check port 8009

---

<div class="post-metadata">

**Author:** ![mrquokka](https://avatars.discourse-cdn.com/v4/letter/m/4af34b/32.png) [@mrquokka](https://discourse.haproxy.org/u/mrquokka)\
**Post date:** [February 1, 2018, 12:35pm UTC](https://discourse.haproxy.org/t/haproxy-loses-connections/2061/2 "2018-02-01T12:35:49Z")

</div>

defaults  
…  
timeout client 30m  
timeout connect 4s  
timeout server 30m  
timeout check 5s

…  
This is my error, sorry
