I have PSQL running, and am trying to get a perl application connecting to the database. Is there a command to find the current port and host that the database is running on
service postgresql status
returns: 10/main (port 5432): online
I'm running Ubuntu 18.04
go to the "Terminal" and just type
service postgres status
In the results you can get the port details
In my case it's running on port "5432" (default).
I'm using CentOS 7.Hope this helps.
SELECT *
FROM pg_settings
WHERE name = 'port';
You can use the command in psql \conninfo
you will get You are connected to database "your_database" as user "user_name" on host "host_name" at port "port_number".
select inet_server_port();
gives you the port of the server.
select inet_server_addr( ), inet_server_port( );