# Frontend TCP connection torn down when one server backed is restarted (ungracefully)

**URL:** https://discourse.haproxy.org/t/frontend-tcp-connection-torn-down-when-one-server-backed-is-restarted-ungracefully/7365
**Category:** Help!
**Created:** [February 5, 2022, 3:39pm UTC](https://discourse.haproxy.org/t/frontend-tcp-connection-torn-down-when-one-server-backed-is-restarted-ungracefully/7365 "2022-02-05T15:39:02Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![mazur\_7](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mazur\_7](https://discourse.haproxy.org/u/mazur_7)
#### Post date: [February 5, 2022, 3:39pm UTC](https://discourse.haproxy.org/t/frontend-tcp-connection-torn-down-when-one-server-backed-is-restarted-ungracefully/7365/1 "2022-02-05T15:39:02Z")

</div>

We use HAProxy with Keepalived to loadbalance traffic and kubernetes master nodes.  
Upon a restart of one backend server (one master) TCP connection is closed to fronted on all remaining nodes (other masters & worker nodes).  
While I could expect it for a subset of nodes i.e. part of frontend TCP connections are closed because connectivity to one backend server is down (well technically it probably times out because reboot is ungraceful), I wouldn’t expect it for all nodes. **It just looks that ALL frontend TCP connections are closed while just SINGLE backend server goes down.** Is that correct behaviour or is there some misconfiguration ?

Config is as below:

```auto
defaults
        log global
        mode http
        option httplog
        option dontlognull
        timeout connect 5000
        timeout client 50000
        timeout server 50000

frontend frontend-api
    bind <backend_ip>:7443
    bind <frontend_ip>:6443
    bind 127.0.0.1:7443
    mode tcp
    option tcplog
    timeout client 300000
    default_backend backend-api

backend backend-api
    mode tcp
    option tcplog
    option tcp-check
    timeout server 300000
    balance roundrobin
    default-server inter 10s downinter 5s rise 2 fall 2 slowstart 60s maxconn 250 maxqueue 256 weight 100

    server master1 <backend_api_ip_srv1>:6443 check
    server master2 <backend_api_ip_srv2>:6443 check
    server master3 <backend_api_ip_srv3>:6443 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: [February 5, 2022, 6:41pm UTC](https://discourse.haproxy.org/t/frontend-tcp-connection-torn-down-when-one-server-backed-is-restarted-ungracefully/7365/2 "2022-02-05T18:41:07Z")

</div>

This is not expected, and I’d be surprised if that is what actually happens here.

Share the logs in tcplog format for review.

---

<div class="post-metadata">

### Author: ![mazur\_7](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mazur\_7](https://discourse.haproxy.org/u/mazur_7)
#### Post date: [February 5, 2022, 8:09pm UTC](https://discourse.haproxy.org/t/frontend-tcp-connection-torn-down-when-one-server-backed-is-restarted-ungracefully/7365/3 "2022-02-05T20:09:06Z")

</div>

Need to check if these are available. But do you mean that for the 1/3rd of connections it is expected but not for remaining 2/3rd ?

---

<div class="post-metadata">

### Author: ![mazur\_7](https://avatars.discourse-cdn.com/v4/letter/m/e47774/32.png) [@mazur\_7](https://discourse.haproxy.org/u/mazur_7)
#### Post date: [February 7, 2022, 11:28am UTC](https://discourse.haproxy.org/t/frontend-tcp-connection-torn-down-when-one-server-backed-is-restarted-ungracefully/7365/4 "2022-02-07T11:28:59Z")

</div>

I don’t have tcplog available… But I have confirmed that Frontend TCP connection is closed (FIN, ACK) when backend connection is closed. So only 1/3rd of connections shall be affected but not all.

---

<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: [February 7, 2022, 11:49am UTC](https://discourse.haproxy.org/t/frontend-tcp-connection-torn-down-when-one-server-backed-is-restarted-ungracefully/7365/5 "2022-02-07T11:49:12Z")

</div>

Expected behavior in TCP mode is that a frontend connection is closed when the server closes the corresponding connection, because there is no other way to handle this scenario.

That doesn’t mean connections going to different server are affected. Likely what you are seeing is that your slaves somehow also close the connection, when the master dies.

That’s why you’d have to look at the behavior haproxy/slaves, not the behavior of the haproxy/master.

Tcpdumps, tcplogs, etc can help here.
