Find the host name and port using PSQL commands

前端 未结 13 2244
眼角桃花
眼角桃花 2020-12-12 11:15

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

13条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-12 11:43

    This command will give you postgres port number

     \conninfo
    

    If postgres is running on Linux server, you can also use the following command

    sudo netstat -plunt |grep postgres
    

    OR (if it comes as postmaster)

    sudo netstat -plunt |grep postmaster
    

    and you will see something similar as this

    tcp        0      0 127.0.0.1:5432          0.0.0.0:*               LISTEN      140/postgres
    tcp6       0      0 ::1:5432                :::*                    LISTEN      140/postgres
    

    in this case, port number is 5432 which is also default port number

    credits link

提交回复
热议问题