Thread: PostgreSQL server listen on other port than 5432
Hi. I'm using CentOS 5.3 and PostgreSQL version 8.1.11. I opened the posgres SQL to accept incoming connections: <snip start from postgresql.conf> listen_addresses = '*' # comma-separated list of addresses; # defaults to 'localhost', '*' = all port = 5432 max_connections = 100 <snip end> It seems that the posgres SQL sometimes listen on other ports than 5432: # lsof -i -n -P | grep postg postmaste 18415 postgres 3u IPv4 99670 TCP *:17583 (LISTEN) postmaste 18415 postgres 4u IPv6 102029 TCP *:5432 (LISTEN) postmaste 18415 postgres 5u IPv4 102030 TCP *:5432 (LISTEN) postmaste 18415 postgres 8u IPv4 102038 UDP 127.0.0.1:53420->127.0.0.1:53420 postmaste 18421 postgres 3u IPv4 99670 TCP *:17583 (LISTEN) postmaste 18423 postgres 3u IPv4 99670 TCP *:17583 (LISTEN) postmaste 18423 postgres 8u IPv4 102038 UDP 127.0.0.1:53420->127.0.0.1:53420 postmaste 18424 postgres 3u IPv4 99670 TCP *:17583 (LISTEN) postmaste 18424 postgres 8u IPv4 102038 UDP 127.0.0.1:53420->127.0.0.1:53420 postmaste 18425 postgres 3u IPv4 99670 TCP *:17583 (LISTEN) postmaste 22242 postgres 3u IPv4 99670 TCP *:17583 (LISTEN) postmaste 22242 postgres 8u IPv4 102038 UDP 127.0.0.1:53420->127.0.0.1:53420 postmaste 22242 postgres 9u IPv4 117409 TCP 127.0.0.1:5432->127.0.0.1:55254 (ESTABLISHED) postmaste 22270 postgres 3u IPv4 99670 TCP *:17583 (LISTEN) postmaste 22270 postgres 8u IPv4 102038 UDP 127.0.0.1:53420->127.0.0.1:53420 postmaste 22270 postgres 9u IPv4 117489 TCP 127.0.0.1:5432->127.0.0.1:55256 (ESTABLISHED) The extra port which is being used (17583) is a port that i need to other services. Did anyone see this issue? Thanks Dotan
Dotan Barak wrote: > Hi. > > I'm using CentOS 5.3 and PostgreSQL version 8.1.11. > > I opened the posgres SQL to accept incoming connections: > > <snip start from postgresql.conf> > listen_addresses = '*' > # comma-separated list of addresses; > # defaults to 'localhost', '*' = all > port = 5432 > max_connections = 100 > <snip end> > > It seems that the posgres SQL sometimes listen on other ports than 5432: > # lsof -i -n -P | grep postg > postmaste 18415 postgres 3u IPv4 99670 TCP *:17583 (LISTEN) > postmaste 18415 postgres 4u IPv6 102029 TCP *:5432 (LISTEN) > postmaste 18415 postgres 5u IPv4 102030 TCP *:5432 (LISTEN) Never seen this before. One thing that does leap out though is that you've got IPv4 and IPv6 sockets active at the same time. Does grepping for "17583" show anything useful? -- Richard Huxton Archonet Ltd
Thanks for the quick response. On Thu, Jul 30, 2009 at 11:26 AM, Richard Huxton<dev@archonet.com> wrote: > Dotan Barak wrote: >> >> Hi. >> >> I'm using CentOS 5.3 and PostgreSQL version 8.1.11. >> >> I opened the posgres SQL to accept incoming connections: >> >> <snip start from postgresql.conf> >> listen_addresses = '*' >> # comma-separated list of addresses; >> # defaults to 'localhost', '*' = all >> port = 5432 >> max_connections = 100 >> <snip end> >> >> It seems that the posgres SQL sometimes listen on other ports than 5432: >> # lsof -i -n -P | grep postg >> postmaste 18415 postgres 3u IPv4 99670 TCP *:17583 (LISTEN) >> postmaste 18415 postgres 4u IPv6 102029 TCP *:5432 (LISTEN) >> postmaste 18415 postgres 5u IPv4 102030 TCP *:5432 (LISTEN) > > Never seen this before. One thing that does leap out though is that you've > got IPv4 and IPv6 sockets active at the same time. Does grepping for "17583" > show anything useful? grep on what? (on ps: there isn't anything). Dotan
Dotan Barak wrote: > > grep on what? > (on ps: there isn't anything). I was thinking of something like: # find /etc -type f -print0 | xargs -0 grep 17583 -- Richard Huxton Archonet Ltd
On Thu, Jul 30, 2009 at 12:14 PM, Richard Huxton<dev@archonet.com> wrote: > Dotan Barak wrote: >> >> grep on what? >> (on ps: there isn't anything). > > I was thinking of something like: > # find /etc -type f -print0 | xargs -0 grep 17583 Thanks for clearing this point; Empty string was found. Dotan
Dotan Barak <dotanba@gmail.com> writes: > I'm using CentOS 5.3 and PostgreSQL version 8.1.11. Are you using the Red Hat/CentOS postgresql RPMs, or some other distribution of PG? > It seems that the posgres SQL sometimes listen on other ports than 5432: > # lsof -i -n -P | grep postg > postmaste 18415 postgres 3u IPv4 99670 TCP *:17583 (LISTEN) > postmaste 18415 postgres 4u IPv6 102029 TCP *:5432 (LISTEN) > postmaste 18415 postgres 5u IPv4 102030 TCP *:5432 (LISTEN) Odd, particularly seeing that that port was evidently opened before 5432. The only idea that comes to mind is that it's being opened by a library for Kerberos or LDAP or some such. What auth methods have you got listed in pg_hba.conf? regards, tom lane
On Thu, Jul 30, 2009 at 5:33 PM, Tom Lane<tgl@sss.pgh.pa.us> wrote: > Dotan Barak <dotanba@gmail.com> writes: >> I'm using CentOS 5.3 and PostgreSQL version 8.1.11. > > Are you using the Red Hat/CentOS postgresql RPMs, or some other > distribution of PG? Yes, I'm using the original RPM that comes with CentOS. > >> It seems that the posgres SQL sometimes listen on other ports than 5432: >> # lsof -i -n -P | grep postg >> postmaste 18415 postgres 3u IPv4 99670 TCP *:17583 (LISTEN) >> postmaste 18415 postgres 4u IPv6 102029 TCP *:5432 (LISTEN) >> postmaste 18415 postgres 5u IPv4 102030 TCP *:5432 (LISTEN) > > Odd, particularly seeing that that port was evidently opened before > 5432. The only idea that comes to mind is that it's being opened by > a library for Kerberos or LDAP or some such. What auth methods have > you got listed in pg_hba.conf? > > regards, tom lane > "trust all". The weird thing is that i used this port in a service that i wrote only few seconds before this happened... Dotan
Dotan Barak <dotanba@gmail.com> writes: > The weird thing is that i used this port in a service that i wrote > only few seconds before this happened... Oh? How'd you start that service exactly? I'm thinking maybe the postmaster inherited the open file from its parent process. If it's not marked close-on-exec, which evidently it's not since the child processes have it too, then this could have happened as far as Postgres itself is concerned. I'm having a bit of a hard time imagining how an open file could have gotten transmitted from some other initscript to this one, but it seems more probable than any other theory at the moment. Do any other processes besides PG have that socket open? If you stop and restart the postmaster, does it open the socket again? regards, tom lane
Hi. On Thu, Jul 30, 2009 at 7:33 PM, Tom Lane<tgl@sss.pgh.pa.us> wrote: > Dotan Barak <dotanba@gmail.com> writes: >> The weird thing is that i used this port in a service that i wrote >> only few seconds before this happened... > > Oh? How'd you start that service exactly? > > I'm thinking maybe the postmaster inherited the open file from its > parent process. If it's not marked close-on-exec, which evidently > it's not since the child processes have it too, then this could have > happened as far as Postgres itself is concerned. I'm having a bit of > a hard time imagining how an open file could have gotten transmitted > from some other initscript to this one, but it seems more probable > than any other theory at the moment. > > Do any other processes besides PG have that socket open? If you stop > and restart the postmaster, does it open the socket again? I guess you hit the spot: I have a service that I wrote in python which uses port 17583. This process restart the postgres SQL service using "/etc/init.d/postgres restart" I think that this may be related to this problem ... I will mark the socket as close on exec. Thanks!!!! Dotan