Can't connect to Postgresql on port 5432

后端 未结 6 1948
隐瞒了意图╮
隐瞒了意图╮ 2020-12-04 19:46

I have PostgreSQL 9.3 installed on a server running Ubuntu Server 14.04.

If I ssh into the server via terminal, I\'m able to connect with psql. But when I try to con

6条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2020-12-04 19:59

    You have to edit postgresql.conf file and change line with 'listen_addresses'.

    This file you can find in the /etc/postgresql/9.3/main directory.

    Default Ubuntu config have allowed only localhost (or 127.0.0.1) interface, which is sufficient for using, when every PostgreSQL client work on the same computer, as PostgreSQL server. If you want connect PostgreSQL server from other computers, you have change this config line in this way:

    listen_addresses = '*'
    

    Then you have edit pg_hba.conf file, too. In this file you have set, from which computers you can connect to this server and what method of authentication you can use. Usually you will need similar line:

    host    all         all         192.168.1.0/24        md5
    

    Please, read comments in this file...

    EDIT:

    After the editing postgresql.conf and pg_hba.conf you have to restart postgresql server.

    EDIT2: Highlited configuration files.

提交回复
热议问题