# Information on logging

**URL:** <https://discourse.haproxy.org/t/information-on-logging/8370>\
**Category:** Help!\
**Created:** [February 8, 2023, 7:08am UTC](https://discourse.haproxy.org/t/information-on-logging/8370 "2023-02-08T07:08:32Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![sreejith](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@sreejith](https://discourse.haproxy.org/u/sreejith)\
**Post date:** [February 8, 2023, 7:08am UTC](https://discourse.haproxy.org/t/information-on-logging/8370/1 "2023-02-08T07:08:32Z")

</div>

hi,  
I am trying to do a haproxy setup with PostgreSQL and Patroni. Following is my configuration.

global  
log stdout local0 info

defaults  
log global  
mode http  
option httplog  
timeout client 10s  
timeout connect 5s  
timeout server 10s  
timeout http-request 10s

listen stats  
mode http  
bind \*:7000  
stats enable  
stats uri /

listen pgReadWrite  
bind \*:5000  
option pgsql-check user postgres  
default-server inter 3s fall 3  
server is1 is1:5432 check port 5432  
server is2 is2:5432 check port 5432

listen pgReadOnly  
bind \*:5001  
option pgsql-check user postgres  
default-server inter 3s fall 3  
server is1 is1:5432 check port 5432  
server is2 is2:5432 check port 5432

When I execute psql command with -p 5000/5001 option it is not returning any error/success. Also I am not able to get log from haproxy whether the DB connection is proper. Is there any way to update the log level(to get more logs) in order to debug this issue? thank you for the support in advance.

---

<div class="post-metadata">

**Author:** ![stormrover](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/stormrover/32/1847_2.png) [@stormrover](https://discourse.haproxy.org/u/stormrover)\
**Post date:** [February 8, 2023, 11:26pm UTC](https://discourse.haproxy.org/t/information-on-logging/8370/2 "2023-02-08T23:26:28Z")

</div>

The default works for most systems:

```auto
global
        log /dev/log local0
        log /dev/log local1 notice

```

On Debian, this outputs to `/var/log/haproxy.log`.

---

<div class="post-metadata">

**Author:** ![sreejith](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@sreejith](https://discourse.haproxy.org/u/sreejith)\
**Post date:** [February 9, 2023, 7:54am UTC](https://discourse.haproxy.org/t/information-on-logging/8370/3 "2023-02-09T07:54:13Z")

</div>

thank you for the update. I am using haproxy with postgreSQL and getting following error when trying to connect using  
$ psql -h localhost -p 5000 -U postgres  
psql: error: received invalid response to SSL negotiation: H

Following log is observed from haproxy.  
\<134\>Feb 9 07:50:26 haproxy[189356]: 127.0.0.1:56212 [09/Feb/2023:07:50:26.604] pgReadWrite pgReadWrite/ -1/-1/-1/-1/0 400 211 - - PR-- 1/1/0/0/3 0/0 “”

Any information on this error will be helpful.

---

<div class="post-metadata">

**Author:** ![stormrover](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/stormrover/32/1847_2.png) [@stormrover](https://discourse.haproxy.org/u/stormrover)\
**Post date:** [February 9, 2023, 12:22pm UTC](https://discourse.haproxy.org/t/information-on-logging/8370/4 "2023-02-09T12:22:35Z")

</div>

`PR--` means that HAProxy blocked/denied your request. In TCP mode, this might mean that your servers are not healthy. Do you have additional logs from starting HAProxy that show if `is1` and `is2` are healthy?

```auto
     PR The proxy blocked the client's HTTP request, either because of an
          invalid HTTP syntax, in which case it returned an HTTP 400 error to
          the client, or because a deny filter matched, in which case it
          returned an HTTP 403 error. It may also be due to an HTTP header
          rewrite failure on the request. In this case, an HTTP 500 error is
          sent (see "tune.maxrewrite" and "http-request strict-mode" for more
          inforomation).

```

Source: [HAProxy version 2.6.8-4 - Configuration Manual - Session state at disconnection](http://docs.haproxy.org/2.6/configuration.html#8.5)

---

<div class="post-metadata">

**Author:** ![sreejith](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@sreejith](https://discourse.haproxy.org/u/sreejith)\
**Post date:** [February 9, 2023, 7:12pm UTC](https://discourse.haproxy.org/t/information-on-logging/8370/5 "2023-02-09T19:12:24Z")

</div>

thank you for the explanation.  
I commented out ‘mode http’ in the defaults section and it starts connecting like below.  
[core@is1 ~]$ psql -U postgres -h 127.0.0.1 -p 5001  
psql (13.7)  
Type “help” for help.

postgres=#

Didn’t understand why http request is blocking connection to PostgreSQL ?

---

<div class="post-metadata">

**Author:** ![stormrover](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/stormrover/32/1847_2.png) [@stormrover](https://discourse.haproxy.org/u/stormrover)\
**Post date:** [February 9, 2023, 7:15pm UTC](https://discourse.haproxy.org/t/information-on-logging/8370/6 "2023-02-09T19:15:22Z")

</div>

Short answer: because PostgreSQL doesn’t speak HTTP. It’s is like pointing a browser at Postgres. Databases cannot respond directly to HTTP requests. They need an application to do that. 🙂

---

<div class="post-metadata">

**Author:** ![sreejith](https://avatars.discourse-cdn.com/v4/letter/s/e9bcb4/32.png) [@sreejith](https://discourse.haproxy.org/u/sreejith)\
**Post date:** [February 10, 2023, 6:12am UTC](https://discourse.haproxy.org/t/information-on-logging/8370/7 "2023-02-10T06:12:19Z")

</div>

Got it … Thank you !!!
