postgresqlpgadmin-4

Postgres: Query the server name, IP address and the name of the instances running on the server


Is it possible to query the name and the IP address of a Postgres server (where the Postgres DBMS is running) (not the hostname or host IP address).

Also, I was looking for a query to get the name of each instance running on the server.

like here the instance test.

I could not find anything to get this information via any query.

I am working on a project for my degree, and I really appreciate any help.


Solution

  • You can get the IP address of the PostgreSQL server with

    SELECT inet_server_addr();
    

    Note that the result depends on the network interface you used to connect (the server may have several different IP addresses).

    There is no query to that can give you information about other instances running on the same machine; each instance has no idea about any other instances.