PostgreSQL inet_server_addr() Function
The PostgreSQL inet_server_addr()
function returns the IP address of the server that accepts the current connection, or if the current connection is connected through a Unix socket NULL
.
inet_server_addr()
Syntax
Here is the syntax of the PostgreSQL inet_server_addr()
function:
inet_server_addr() -> inet
Parameters
The PostgreSQL inet_server_addr()
function does not require any parameters.
Return value
The PostgreSQL inet_server_addr()
function returns the IP address of the server that accepts the current connection, or if the current connection is connected through a Unix socket NULL
.
inet_server_addr()
Examples
To get the IP address of the PostgreSQL server, use the following statement with the inet_server_addr()
function:
SELECT inet_server_addr();
inet_server_addr
------------------
::1
Here, ::1
is the IPv6 address, representing the local machine.