0

I've encountered a problem while trying to setup firewall rules for postgres (server ubuntu 22.04, postgres 14). Postgres has been configured and working OK, with firewall disabled I could connect to db from outside. With firewall enabled (rule for port 5432 added of course) connection hangs. Investigating firewall logs I've seen blocked connections to udp port 51556 from my machine while trying to establish connection to postgres. Opening that port in firewall solved the problem. So: what is the port 51556 for? Cannot found any info about it. Cheers Paweł

Problem had been solved, but I'm just curious ;-)

1 Answers1

0

It's for the server to communicate with its statistics collection process. The port is different for each installation.

https://www.postgresql.org/message-id/21283.1008989228%40sss.pgh.pa.us

Tim Roberts
  • 48,973
  • 4
  • 21
  • 30
  • Thank a lot, I've found that thread already but read it without understanding :-( It leads to next question: the connection to statistics collection process is done "inside" the postgresql host – Pawel Szubert Jun 25 '23 at 08:33
  • Why is firewall blocking incoming connection? Local connection can be established without firewall exception for that port - that was what mislead my previous investigation. – Pawel Szubert Jun 25 '23 at 08:42
  • This answer makes no sense, the statistics collection is a local operation per [Statistics](https://www.postgresql.org/docs/current/monitoring-stats.html). It's port is local only and I have never seen a firewall setup that included it. – Adrian Klaver Jun 25 '23 at 15:39
  • 2
    @PawelSzubert "Local connection can be established without firewall exception " Are you sure? A local firewall could block such connections if it wanted to. Since we don't know what your firewall is or how it is configured.... – jjanes Jun 25 '23 at 18:21
  • @jjanes: Yes, double checked it yesterday and some minutes ago again. I have a service connecting to postgresql databse. This service connects to db without any problem on the dbhost despite the existence of exception for 51556/udp port, running on my machine it works ONLY IF that firewall exception exists. Without the exception I'm getting connection error. No ither changes to firewall rules ware made (ufw on Ubuntu 22.04) – Pawel Szubert Jun 26 '23 at 13:18