remote connection error:could not connect to server: Connection refused
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?
Alex Luya <alexander.luya@gmail.com> writes:
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*
Since your netstat results show that the postmaster is still listening
only on "localhost" (the default), the most obvious theory is that you
failed to edit the configuration file that's actually being used.
Assuming you can connect at all, "show config_file;" would be a reliable
way of identifying which file that is. (Almost certainly, it won't be
in /usr/pgsql-9.4/share.)
Also, I do not know what reference you are looking at that suggests
setting "tcpip_socket", but no such configuration parameter has existed
in Postgres in a very long time. If you had edited the active config
file like that, Postgres would have refused to start. Setting
listen_addresses = "*" should be sufficient.
BTW, I do *not* recommend overwriting the config file generated by initdb
with some sample file like that. You'll lose the configuration values
selected by initdb, which typically isn't a good idea.
regards, tom lane
--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general