My haproxy configuration is as below, in the backend there is pg_autoctl cluster, another VM (bunty4) hosts the monitor and haproxy is installed on it.
global
maxconn 100
defaults
log global
mode tcp
retries 2
timeout client 30m
timeout connect 4s
timeout server 30m
timeout check 5s
listen stats
mode tcp
bind *:7000
stats enable
stats uri /
listen ReadWrite
bind *:5000
option httpchk
http-check expect status 200
default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions
server bunty1 bunty1:6001 maxconn 100 check port 23267
server bunty2 bunty2:6002 maxconn 100 check port 23267
server bunty3 bunty3:6003 maxconn 100 check port 23267
listen ReadOnly
bind *:5001
option httpchk
http-check expect status 206
default-server inter 3s fall 3 rise 2 on-marked-down shutdown-sessions
server bunty1 bunty1:6001 maxconn 100 check port 23267
server bunty2 bunty2:6002 maxconn 100 check port 23267
server bunty3 bunty3:6003 maxconn 100 check port 23267
This runs fine:
postgres@bunty4:~$ psql -h bunty2 -p 6002
psql (14.6 (Ubuntu 14.6-1.pgdg22.04+1))
Type "help" for help.
postgres=# \q
postgres@bunty4:~$ psql -h bunty1 -p 6001
psql (14.6 (Ubuntu 14.6-1.pgdg22.04+1))
Type "help" for help.
When I try to connect frontend port 7000 (thru pgadmin or cli) it gives an error:
postgres@bunty4:~$ psql -h localhost -p 7000
psql: error: connection to server at "localhost" (127.0.0.1), port 7000 failed: server closed the connection unexpectedly
This probably means the server terminated abnormally
before or while processing the request.
psql -h 192.168.5.129 -p 7000 ## this also fails with same error.
Not sure why, haproxy.log doesn't throw up anything.