# Haproxy 2.0.6 - nbsrv is not working

**URL:** https://discourse.haproxy.org/t/haproxy-2-0-6-nbsrv-is-not-working/7949
**Category:** Help!
**Created:** [September 9, 2022, 12:45pm UTC](https://discourse.haproxy.org/t/haproxy-2-0-6-nbsrv-is-not-working/7949 "2022-09-09T12:45:31Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Vels456](https://avatars.discourse-cdn.com/v4/letter/v/df705f/32.png) [@Vels456](https://discourse.haproxy.org/u/Vels456)
#### Post date: [September 9, 2022, 12:45pm UTC](https://discourse.haproxy.org/t/haproxy-2-0-6-nbsrv-is-not-working/7949/1 "2022-09-09T12:45:31Z")

</div>

Hi Mates,

I have this below config, my requirement is to route the requests if `main-backend`’s available servers becomes 1 out of 2, so I tried nbsrv, but ended up with some problem there which is not working as expected

```auto
frontend myApplication 
  bind :::443 ssl crt <cert/location> 
  log global 
  maxconn 10000
  acl main_is_down nbsrv(main-backend) le 1
  use_backend backup-backend if main_is_down
  default_backend main-backend

backend main-backend 
  option httpchk GET /healthCheck
  server server1 1.2.3.4:8080 maxconn 100 check 
  server server2 1.2.3.5:8080 maxconn 100 check    

backend backup-backend 
   option httpchk GET /healthCheck
   server backup-server1 2.1.3.4:8080 maxconn 100 check
  server backup-server2 2.1.3.5:8080 maxconn 100 check

```

All the servers in `main-backend` is down, request is getting failed with 503 since both the servers in main-backend is down

Could you please help in suggesting the changes in this config to make it work so that I can forward the requests to `backup-backend` ?

Thanks in Advance!

---

<div class="post-metadata">

### Author: ![Markus](https://avatars.discourse-cdn.com/v4/letter/m/b782af/32.png) [@Markus](https://discourse.haproxy.org/u/Markus)
#### Post date: [September 9, 2022, 1:43pm UTC](https://discourse.haproxy.org/t/haproxy-2-0-6-nbsrv-is-not-working/7949/2 "2022-09-09T13:43:57Z")

</div>

I have a Fallback Setup with two single servers  
frontend uses “use\_backend master” for the requests, in backend there is a backup-setup.

```auto
backend master
    server master 1.2.3.4:443 maxconn 140 check weight 1 inter 5s rise 3 fall 2
    server slave 1.2.3.5:443 maxconn 100 check backup weight 1 inter 5s rise 3 fall 2

```

server slave only get connections if master does not answer some number of requests in a certain time.  
if master is up again, all requests are routed to master again…

---

<div class="post-metadata">

### Author: ![Vels456](https://avatars.discourse-cdn.com/v4/letter/v/df705f/32.png) [@Vels456](https://discourse.haproxy.org/u/Vels456)
#### Post date: [September 9, 2022, 1:49pm UTC](https://discourse.haproxy.org/t/haproxy-2-0-6-nbsrv-is-not-working/7949/3 "2022-09-09T13:49:11Z")

</div>

How this can work in production case? If we have more than one as main servers, haproxy will not route the traffic to backup until all the main are going down…

I need to route the traffic to backup if some number of main backend are down(2 are down out of 5), so I decided to go with nbsrv instead of using backup keyword in the same backend config

---

<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: [September 12, 2022, 8:59pm UTC](https://discourse.haproxy.org/t/haproxy-2-0-6-nbsrv-is-not-working/7949/4 "2022-09-12T20:59:21Z")

</div>

> [@Vels456](#):
>
> All the servers in `main-backend` is down, request is getting failed with 503 since both the servers in main-backend is down
> 
> Could you please help in suggesting the changes in this config to make it work so that I can forward the requests to `backup-backend` ?

I can’t see anything wrong with your configuration on a first glance.

Enable proper logging, reproduce the issue and provide the logs:

> [@How to enable HAProxy Stats Log](https://discourse.haproxy.org/t/how-to-enable-haproxy-stats-log/1738/2):
>
> You can find the details of the logging system in the documentation, section 8 [1]. As an example, here is a basic logging configuration: global log 127.0.0.1 syslog debug defaults log global mode http option httplog [1] [https://cbonte.github.io/haproxy-dconv/1.7/configuration.html#8](https://cbonte.github.io/haproxy-dconv/1.7/configuration.html#8)
