RE: TCP/IP connections refused

From: <soumik(dot)bhattacharjee(at)kpn(dot)com>
To: <rammohanganap(at)gmail(dot)com>
Cc: <siddharth(dot)karandikar(at)gmail(dot)com>, <pgsql-admin(at)postgresql(dot)org>, <pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: RE: TCP/IP connections refused
Date: 2020-10-30 08:50:37
Message-ID: d994360312bd49078f0e61c7702c96e8@kpn.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-admin

Thanks Rammohan.

From: rammohan ganapavarapu <rammohanganap(at)gmail(dot)com>
Sent: donderdag 29 oktober 2020 16:27
To: Bhattacharjee, Soumik <soumik(dot)bhattacharjee(at)kpn(dot)com>
Cc: siddharth(dot)karandikar(at)gmail(dot)com; pgsql-admin <pgsql-admin(at)postgresql(dot)org>; pgsql-admin(at)lists(dot)postgresql(dot)org
Subject: Re: TCP/IP connections refused

On the client machine if you have telnet or nc utilities, can u check below?

telnet <pg server ip> 5432 or

nc -z <pg server ip> 5432 - v

This will tell you if your FW is accepting connection.

On Thu, Oct 29, 2020, 4:45 AM <soumik(dot)bhattacharjee(at)kpn(dot)com<mailto:soumik(dot)bhattacharjee(at)kpn(dot)com>> wrote:
Hi Siddharth,

Yes, java microservice are hosted on separate machine running on kubernetes/docker.

I have used command ss -nt dst 10.133.214.30/30<http://10.133.214.30/30> to check whether we are able to connect to the DB server.
State is not established.

[cid:image003(dot)jpg(at)01D6ADF1(dot)5053EF90]

From: Siddharth Karandikar <siddharth(dot)karandikar(at)gmail(dot)com<mailto:siddharth(dot)karandikar(at)gmail(dot)com>>
Sent: donderdag 29 oktober 2020 11:34
To: Bhattacharjee, Soumik <soumik(dot)bhattacharjee(at)kpn(dot)com<mailto:soumik(dot)bhattacharjee(at)kpn(dot)com>>
Cc: pgsql-admin <pgsql-admin(at)postgresql(dot)org<mailto:pgsql-admin(at)postgresql(dot)org>>; pgsql-admin(at)lists(dot)postgresql(dot)org<mailto:pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Re: TCP/IP connections refused

Soumik, you tested from localhost which is the DB machine itself. And that is expected to work given the status information you shared in the first email.

Is your java microservice running on separate machine? on separate network?
Can you connect from that machine/network to postgres server by using any client (e.g. psql)?

On Thu, Oct 29, 2020 at 3:49 PM <soumik(dot)bhattacharjee(at)kpn(dot)com<mailto:soumik(dot)bhattacharjee(at)kpn(dot)com>> wrote:
Yes. Its working from my local also.

$ psql -h localhost -p 5432
Password for user postgres:
psql (12.1 (Debian 12.1-1.pgdg100+1))
SSL connection (protocol: TLSv1.3, cipher: TLS_AES_256_GCM_SHA384, bits: 256, compression: off)
Type "help" for help.

postgres=#

From: Siddharth Karandikar <siddharth(dot)karandikar(at)gmail(dot)com<mailto:siddharth(dot)karandikar(at)gmail(dot)com>>
Sent: donderdag 29 oktober 2020 10:33
To: Bhattacharjee, Soumik <soumik(dot)bhattacharjee(at)kpn(dot)com<mailto:soumik(dot)bhattacharjee(at)kpn(dot)com>>
Cc: pgsql-admin <pgsql-admin(at)postgresql(dot)org<mailto:pgsql-admin(at)postgresql(dot)org>>; pgsql-admin(at)lists(dot)postgresql(dot)org<mailto:pgsql-admin(at)lists(dot)postgresql(dot)org>
Subject: Re: TCP/IP connections refused

Did you try connecting to it using `psql`? Do you get the same error with that?

On Thu, Oct 29, 2020 at 1:48 PM <soumik(dot)bhattacharjee(at)kpn(dot)com<mailto:soumik(dot)bhattacharjee(at)kpn(dot)com>> wrote:
Hi Experts,

We are trying to connect from Java(Microservices) applications to Database and getting below issues :

org.postgresql.util.PSQLException: Connection to XXXXXXX:5432 refused. Check that the hostname and port are correct and that the postmaster is accepting TCP/IP connections.

Please suggest your inputs and suggestions for solution.

The things I did :

1. Firewall/Ports are open from DB server for inbound traffic.
2. Added application IP ranges in pg_hba.conf file and restarted the Postgres instance.
3. The listen_addresses=’*’ is set to.
4. $ lsof -n -u postgres |grep LISTEN

postgres 26802 postgres 3u IPv4 19104770 0t0 TCP *:postgresql (LISTEN)

postgres 26802 postgres 4u IPv6 19104771 0t0 TCP *:postgresql (LISTEN)

1. $ netstat -ltnp | grep postgres

(Not all processes could be identified, non-owned process info

will not be shown, you would have to be root to see it all.)

tcp 0 0 0.0.0.0:5432<http://0.0.0.0:5432> 0.0.0.0:* LISTEN 26802/postgres

tcp6 0 0 :::5432 :::* LISTEN 26802/postgres

1. $ cat /etc/postgresql/12/main/postgresql.conf | grep port

port = 5432 # (change requires restart)

#ssl_passphrase_command_supports_reload = off

Thanks

In response to

Browse pgsql-admin by date

  From Date Subject
Next Message John Scalia 2020-10-30 16:52:49 Creating a partition table
Previous Message rammohan ganapavarapu 2020-10-29 15:26:30 Re: TCP/IP connections refused