pg_inet_addr
pg_inet_addr · Lists the IPv4 and IPv6 addresses and netmasks assigned to the PostgreSQL server host network interfaces.
Overview
| ID | Extension | Package | Version | Category | License | Language |
|---|---|---|---|---|---|---|
| 100608 | pg_inet_addr | pg_inet_addr | 1.0 | STAT | BSD-3-Clause | C |
PostgreSQL · 10, 11, 12, 13, 14, 15, 16, 17, 18
Usage
Sources:
pg_inet_addr lists IPv4 and IPv6 addresses assigned to the operating-system interfaces visible to the PostgreSQL backend. It is useful for local or Unix-socket connections where PostgreSQL’s inet_server_addr() can return NULL.
Core Workflow
The extension installs its function in pg_catalog and revokes its EXECUTE privilege from PUBLIC. A superuser or owner must grant access deliberately.
Query all interfaces or filter by family and interface name.
Returned Columns
interface: operating-system interface name.address: interface address formatted as text.netmask: interface netmask formatted as text.family:IPv4orIPv6.
The function is declared VOLATILE and returns a fresh snapshot on each call. Both addresses and netmasks are text, so cast only after filtering or validating values. Link-local IPv6 addresses can include a scope suffix such as %eth0.
Operational Notes
Results describe the network namespace of the PostgreSQL server process, not the client’s network, DNS name, load-balancer address, or public endpoint. In containers, this normally means the container or pod namespace. Interfaces can appear or disappear between calls, and the function does not identify which address accepts PostgreSQL traffic.
The implementation relies on the host’s getifaddrs interface and is intended for Unix-like systems. Because the output reveals host networking details, keep the default privilege boundary unless a monitoring role specifically needs it.