inet_client_addr()

A function returning the client IP address

inet_client_addr() is a system function which returns the IP address of the current client.

inet_client_addr() was added in PostgreSQL 8.0.

Usage

inet_client_addr () → inet

inet_client_addr() is called without any arguments, and returns the client IP address as the inet data type, or NULL if the current connection is via a Unix-domain socket.

Change history

Examples

Example output when connected via TCP/IP:

postgres=# SELECT inet_client_addr();
 inet_client_addr
------------------
 10.11.9.5
(1 row)

Example output when connected via a Unix-domain socket:

postgres=# SELECT inet_client_addr();
 inet_client_addr
------------------

(1 row)

Categories

System function

See also

inet_client_port(), inet_server_addr(), pg_stat_get_backend_client_addr()