Home > Software design >  understanding binding ports while sending pg_dump command on remote postgres server
understanding binding ports while sending pg_dump command on remote postgres server

Time:08-25

i actually use a dbeaver client which executes a pg_dump command on a remote server. The command starts exactly like that :

pg_dump --verbose --host=127.0.0.1 --port=47855 --username=user-accounet..

i dont't know how dbeaver creates ssh tunnel (it uses a bastion) but, it is not the question. the question is : when i excute the command below..

lsof -i -P -n | grep pg_dump

i get this :

pg_dump   14144 parcss-alexco    3u  IPv4 397966      0t0  TCP 127.0.0.1:35978->127.0.0.1:47855 (ESTABLISHED)

what is this adress ip : 35978 ? what kind of binding 35978 --> 47855 means ? Does it concern a remote ip adresse ? local ? i'd like to understand..

CodePudding user response:

A TCP connection is between to sockets. A fully specified socket has an IP address and a port number.

pg_dump uses port 47855 on 127.0.0.1 for the remote socket for the connection, but what about the socket on the other end? The IP address is clear, but what is the port number? Since the socket is not explicitly bound to a certain port with bind(2), connect(2) will assign an “ephemeral port” number. This happens to be 35978 in your case.

  • Related