remote connection error:could not connect to server: Connection refused

From: Alex Luya <alexander(dot)luya(at)gmail(dot)com>
To: pgsql-general(at)postgresql(dot)org
Subject: remote connection error:could not connect to server: Connection refused
Date: 2015-11-21 15:26:25
Message-ID: CAL6j_s_0ia3dk+dYmy6GDWg1iyN_u+OybX7bQp5qufZDseJuug@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

My postgresql 9.4 is installed in centos 6.7,and I have followed this:

http://www.cyberciti.biz/faq/postgresql-remote-access-or-connection/

1,cd /usr/pgsql-9.4/share/

2,cp postgresql.conf.sample postgresql.conf

3,sudo vi postgresql.conf and add two lines,and save it:

> *listen_addresses = "*"tcpip_socket = true*

4,cp pg_hba.conf.sample pg_hba.conf

5,sudo vi pg_hba.conf then *commented(maybe this is uneccessary)*

> #host all all 127.0.0.1/32
> @authmethodhost@
> #host all all ::1/128
> @authmethodhost@

6,add two lines:(I have tried to change *md5 to trust*,neither works)

>
> *host all all 0.0.0.0/0 <http://0.0.0.0/0>
> md5host all all ::0/0
> md5*

7,then *save*:pg_hba.conf

8,then *restart* postgresql sever by

* sudo service postgresql-9.4 restart*

9.*close iptables*

* sudo service iptables stop*

10,and ask another guy in *different city* to try to connect by

psql -U postgres -h *135.211.67.23*

He got error

>
>
> *psql: could not connect to server: Connection refusedIs the server
> running on host "135.211.67.23" and acceptingTCP/IP connections on port
> 5432?*

and I tried to run same some command in the host(centos),got same error.

12.Running: "netstat -lputn" in the host got
.....
tcp 0 0 127.0.0.1:5432 0.0.0.0:*
LISTEN -
....

So,How to solve this problem?

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2015-11-21 15:47:57 Re: remote connection error:could not connect to server: Connection refused
Previous Message Adrian Klaver 2015-11-21 15:17:25 Re: [ADMIN] How to drop stats on table