Thread: pg_stat_activity's client_addr column contains "::1" but actually comes from elsewhere?

pg_stat_activity's client_addr column contains "::1" but actually comes from elsewhere?

From
"Edward J. Sabol"
Date:
Hello! I'm trying to track down where some connections are coming from. "select pid,client_addr,client_hostname from
pg_stat_activity"shows multiple entries with values with client_addr = "::1". "client_hostname" is blank for all
entries,by the way, and unhelpful in this scenario. Also, "state" is "idle" for these entries I'm interested in, in
casethat matters. 

::1 would imply the IPv6 loopback address, so that means the connection is coming from a process on the server, right?
ButI'm positive there is no process on this server that is connecting to PostgreSQL (other than my psql session). 

So where are they actually coming from and why is PostgreSQL seemingly misreporting them as coming from ::1?

Thanks for any help,
Ed




"Edward J. Sabol" <edwardjsabol@gmail.com> writes:
> Hello! I'm trying to track down where some connections are coming from. "select pid,client_addr,client_hostname from
pg_stat_activity"shows multiple entries with values with client_addr = "::1". "client_hostname" is blank for all
entries,by the way, and unhelpful in this scenario. Also, "state" is "idle" for these entries I'm interested in, in
casethat matters. 
> ::1 would imply the IPv6 loopback address, so that means the connection is coming from a process on the server,
right?But I'm positive there is no process on this server that is connecting to PostgreSQL (other than my psql
session).

> So where are they actually coming from and why is PostgreSQL seemingly misreporting them as coming from ::1?

Well, unless the kernel is lying to us, that is where the connection
came from.  Perhaps snooping around with netstat and lsof (if you have
it) would be helpful.

            regards, tom lane



On Nov 16, 2020, at 4:49 PM, Tom Lane <tgl@sss.pgh.pa.us> wrote:
> "Edward J. Sabol" <edwardjsabol@gmail.com> writes:
>> Hello! I'm trying to track down where some connections are coming from. "select pid,client_addr,client_hostname from
pg_stat_activity"shows multiple entries with values with client_addr = "::1". "client_hostname" is blank for all
entries,by the way, and unhelpful in this scenario. Also, "state" is "idle" for these entries I'm interested in, in
casethat matters. 
>> ::1 would imply the IPv6 loopback address, so that means the connection is coming from a process on the server,
right?But I'm positive there is no process on this server that is connecting to PostgreSQL (other than my psql
session).
>
>> So where are they actually coming from and why is PostgreSQL seemingly misreporting them as coming from ::1?
>
> Well, unless the kernel is lying to us, that is where the connection
> came from.  Perhaps snooping around with netstat and lsof (if you have
> it) would be helpful.

Thanks for the reply. We figured out. One of our developers was using an ssh tunnel and connecting over that.

Regards,
Ed




On Mon, Nov 16, 2020 at 4:08 PM Edward J. Sabol <edwardjsabol@gmail.com> wrote:
Hello! I'm trying to track down where some connections are coming from. "select pid,client_addr,client_hostname from pg_stat_activity" shows multiple entries with values with client_addr = "::1". "client_hostname" is blank for all entries, by the way, and unhelpful in this scenario. Also, "state" is "idle" for these entries I'm interested in, in case that matters.

::1 would imply the IPv6 loopback address, so that means the connection is coming from a process on the server, right? But I'm positive there is no process on this server that is connecting to PostgreSQL (other than my psql session).

It could be connected through an SSH tunnel, that will look like it is coming in over the loopback device.

Cheers,

Jeff