Thread: Connection log entries - random port number recorded

Connection log entries - random port number recorded

From
mike g
Date:
Hello,

I have postgres set to log all connections.  I run it on port 5432.  I
have noticed in the postgres logs that the port being used to connect to
the database is logged but never equal to 5432.  The ip address recorded
is correct but the port number recorded is always a different number
each time.

This is 7.4.1-3 on cygwin.  Has anyone noticed this on other platforms?

Mike

Re: Connection log entries - random port number recorded

From
Richard Huxton
Date:
mike g wrote:
> Hello,
>
> I have postgres set to log all connections.  I run it on port 5432.  I
> have noticed in the postgres logs that the port being used to connect to
> the database is logged but never equal to 5432.  The ip address recorded
> is correct but the port number recorded is always a different number
> each time.

This is entirely normal. The database listens on port 5432, but the
client will connect *from* a randomly chosen port (it's not actually
random, but it is meaningless).

You can't have two connections with the same endpoints, i.e. if you open
up one connection and it goes:
   client:12345 => server:5432
then the next outbound connection will have to use a different port e.g.
   client:12346 => server:5432

On linux you can use "lsof -i" to see all current connections, I used to
  use something similar on Windows, but can't remember what it was.

HTH
--
   Richard Huxton
   Archonet Ltd

Re: Connection log entries - random port number recorded

From
"Matt Van Mater"
Date:
>>On linux you can use "lsof -i" to see all current connections, I used to
>>use something similar on >>Windows, but can't remember what it was.

The tool you're looking for is called fport, and is distributed for free by
Foundstone.  It lists which program is using each open port.  Alternatively
you can just use netstat -an to just see which ports are actively
communicating or listening, but it won't show you which program is using
that port.

Matt

_________________________________________________________________
Is your PC infected? Get a FREE online computer virus scan from McAfee�
Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963