pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
TCP/IP connections refused
9+ messages / 4 participants
[nested] [flat]

* TCP/IP connections refused
@ 2020-10-29 08:18 soumik.bhattacharjee@kpn.com
  2020-10-29 09:32 ` Re: TCP/IP connections refused Siddharth Karandikar <siddharth.karandikar@gmail.com>
  2020-10-29 10:05 ` Re: TCP/IP connections refused Sushant Pawar <sushantxp@gmail.com>
  0 siblings, 2 replies; 9+ messages in thread

From: soumik.bhattacharjee@kpn.com @ 2020-10-29 08:18 UTC (permalink / raw)
  To: pgsql-admin; pgsql-admin@lists.postgresql.org

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            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

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: TCP/IP connections refused
  2020-10-29 08:18 TCP/IP connections refused soumik.bhattacharjee@kpn.com
@ 2020-10-29 09:32 ` Siddharth Karandikar <siddharth.karandikar@gmail.com>
  2020-10-29 10:19   ` RE: TCP/IP connections refused soumik.bhattacharjee@kpn.com
  1 sibling, 1 reply; 9+ messages in thread

From: Siddharth Karandikar @ 2020-10-29 09:32 UTC (permalink / raw)
  To: soumik.bhattacharjee@kpn.com; +Cc: pgsql-admin; pgsql-admin@lists.postgresql.org

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.bhattacharjee@kpn.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            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*
>
>
>

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* RE: TCP/IP connections refused
  2020-10-29 08:18 TCP/IP connections refused soumik.bhattacharjee@kpn.com
  2020-10-29 09:32 ` Re: TCP/IP connections refused Siddharth Karandikar <siddharth.karandikar@gmail.com>
@ 2020-10-29 10:19   ` soumik.bhattacharjee@kpn.com
  2020-10-29 10:33     ` Re: TCP/IP connections refused Siddharth Karandikar <siddharth.karandikar@gmail.com>
  0 siblings, 1 reply; 9+ messages in thread

From: soumik.bhattacharjee@kpn.com @ 2020-10-29 10:19 UTC (permalink / raw)
  To: siddharth.karandikar@gmail.com; +Cc: pgsql-admin; pgsql-admin@lists.postgresql.org

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.karandikar@gmail.com>
Sent: donderdag 29 oktober 2020 10:33
To: Bhattacharjee, Soumik <soumik.bhattacharjee@kpn.com>
Cc: pgsql-admin <pgsql-admin@postgresql.org>; pgsql-admin@lists.postgresql.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.bhattacharjee@kpn.com<mailto:soumik.bhattacharjee@kpn.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




^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: TCP/IP connections refused
  2020-10-29 08:18 TCP/IP connections refused soumik.bhattacharjee@kpn.com
  2020-10-29 09:32 ` Re: TCP/IP connections refused Siddharth Karandikar <siddharth.karandikar@gmail.com>
  2020-10-29 10:19   ` RE: TCP/IP connections refused soumik.bhattacharjee@kpn.com
@ 2020-10-29 10:33     ` Siddharth Karandikar <siddharth.karandikar@gmail.com>
  2020-10-29 11:45       ` RE: TCP/IP connections refused soumik.bhattacharjee@kpn.com
  0 siblings, 1 reply; 9+ messages in thread

From: Siddharth Karandikar @ 2020-10-29 10:33 UTC (permalink / raw)
  To: soumik.bhattacharjee@kpn.com; +Cc: pgsql-admin; pgsql-admin@lists.postgresql.org

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.bhattacharjee@kpn.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.karandikar@gmail.com>
> *Sent:* donderdag 29 oktober 2020 10:33
> *To:* Bhattacharjee, Soumik <soumik.bhattacharjee@kpn.com>
> *Cc:* pgsql-admin <pgsql-admin@postgresql.org>;
> pgsql-admin@lists.postgresql.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.bhattacharjee@kpn.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            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*
>
>
>
>

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* RE: TCP/IP connections refused
  2020-10-29 08:18 TCP/IP connections refused soumik.bhattacharjee@kpn.com
  2020-10-29 09:32 ` Re: TCP/IP connections refused Siddharth Karandikar <siddharth.karandikar@gmail.com>
  2020-10-29 10:19   ` RE: TCP/IP connections refused soumik.bhattacharjee@kpn.com
  2020-10-29 10:33     ` Re: TCP/IP connections refused Siddharth Karandikar <siddharth.karandikar@gmail.com>
@ 2020-10-29 11:45       ` soumik.bhattacharjee@kpn.com
  2020-10-29 15:26         ` Re: TCP/IP connections refused rammohan ganapavarapu <rammohanganap@gmail.com>
  0 siblings, 1 reply; 9+ messages in thread

From: soumik.bhattacharjee@kpn.com @ 2020-10-29 11:45 UTC (permalink / raw)
  To: siddharth.karandikar@gmail.com; +Cc: pgsql-admin; pgsql-admin@lists.postgresql.org

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 to check whether we are able to connect to the DB server.
State is not established.

[cid:image003.jpg@01D6ADF1.5053EF90]


From: Siddharth Karandikar <siddharth.karandikar@gmail.com>
Sent: donderdag 29 oktober 2020 11:34
To: Bhattacharjee, Soumik <soumik.bhattacharjee@kpn.com>
Cc: pgsql-admin <pgsql-admin@postgresql.org>; pgsql-admin@lists.postgresql.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.bhattacharjee@kpn.com<mailto:soumik.bhattacharjee@kpn.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.karandikar@gmail.com<mailto:siddharth.karandikar@gmail.com>>
Sent: donderdag 29 oktober 2020 10:33
To: Bhattacharjee, Soumik <soumik.bhattacharjee@kpn.com<mailto:soumik.bhattacharjee@kpn.com>>
Cc: pgsql-admin <pgsql-admin@postgresql.org<mailto:pgsql-admin@postgresql.org>>; pgsql-admin@lists.postgresql.org<mailto:pgsql-admin@lists.postgresql.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.bhattacharjee@kpn.com<mailto:soumik.bhattacharjee@kpn.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




Attachments:

image003.jpg (image/jpeg, 31.0K) download view image
^ permalink raw reply [nested|flat] 9+ messages in thread

* Re: TCP/IP connections refused
  2020-10-29 08:18 TCP/IP connections refused soumik.bhattacharjee@kpn.com
  2020-10-29 09:32 ` Re: TCP/IP connections refused Siddharth Karandikar <siddharth.karandikar@gmail.com>
  2020-10-29 10:19   ` RE: TCP/IP connections refused soumik.bhattacharjee@kpn.com
  2020-10-29 10:33     ` Re: TCP/IP connections refused Siddharth Karandikar <siddharth.karandikar@gmail.com>
  2020-10-29 11:45       ` RE: TCP/IP connections refused soumik.bhattacharjee@kpn.com
@ 2020-10-29 15:26         ` rammohan ganapavarapu <rammohanganap@gmail.com>
  2020-10-30 08:50           ` RE: TCP/IP connections refused soumik.bhattacharjee@kpn.com
  0 siblings, 1 reply; 9+ messages in thread

From: rammohan ganapavarapu @ 2020-10-29 15:26 UTC (permalink / raw)
  To: soumik.bhattacharjee@kpn.com; +Cc: pgsql-admin; pgsql-admin@lists.postgresql.org

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.bhattacharjee@kpn.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.
>
>
>
>
>
>
>
> *From:* Siddharth Karandikar <siddharth.karandikar@gmail.com>
> *Sent:* donderdag 29 oktober 2020 11:34
> *To:* Bhattacharjee, Soumik <soumik.bhattacharjee@kpn.com>
> *Cc:* pgsql-admin <pgsql-admin@postgresql.org>;
> pgsql-admin@lists.postgresql.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.bhattacharjee@kpn.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.karandikar@gmail.com>
> *Sent:* donderdag 29 oktober 2020 10:33
> *To:* Bhattacharjee, Soumik <soumik.bhattacharjee@kpn.com>
> *Cc:* pgsql-admin <pgsql-admin@postgresql.org>;
> pgsql-admin@lists.postgresql.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.bhattacharjee@kpn.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            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*
>
>
>
>

Attachments:

image003.jpg (image/jpeg, 31.0K) download view image
image003.jpg (image/jpeg, 31.0K) download view image
^ permalink raw reply [nested|flat] 9+ messages in thread

* RE: TCP/IP connections refused
  2020-10-29 08:18 TCP/IP connections refused soumik.bhattacharjee@kpn.com
  2020-10-29 09:32 ` Re: TCP/IP connections refused Siddharth Karandikar <siddharth.karandikar@gmail.com>
  2020-10-29 10:19   ` RE: TCP/IP connections refused soumik.bhattacharjee@kpn.com
  2020-10-29 10:33     ` Re: TCP/IP connections refused Siddharth Karandikar <siddharth.karandikar@gmail.com>
  2020-10-29 11:45       ` RE: TCP/IP connections refused soumik.bhattacharjee@kpn.com
  2020-10-29 15:26         ` Re: TCP/IP connections refused rammohan ganapavarapu <rammohanganap@gmail.com>
@ 2020-10-30 08:50           ` soumik.bhattacharjee@kpn.com
  0 siblings, 0 replies; 9+ messages in thread

From: soumik.bhattacharjee@kpn.com @ 2020-10-30 08:50 UTC (permalink / raw)
  To: rammohanganap@gmail.com; +Cc: siddharth.karandikar@gmail.com; pgsql-admin; pgsql-admin@lists.postgresql.org

Thanks Rammohan.

From: rammohan ganapavarapu <rammohanganap@gmail.com>
Sent: donderdag 29 oktober 2020 16:27
To: Bhattacharjee, Soumik <soumik.bhattacharjee@kpn.com>
Cc: siddharth.karandikar@gmail.com; pgsql-admin <pgsql-admin@postgresql.org>; pgsql-admin@lists.postgresql.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.bhattacharjee@kpn.com<mailto:soumik.bhattacharjee@kpn.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.jpg@01D6ADF1.5053EF90]


From: Siddharth Karandikar <siddharth.karandikar@gmail.com<mailto:siddharth.karandikar@gmail.com>>
Sent: donderdag 29 oktober 2020 11:34
To: Bhattacharjee, Soumik <soumik.bhattacharjee@kpn.com<mailto:soumik.bhattacharjee@kpn.com>>
Cc: pgsql-admin <pgsql-admin@postgresql.org<mailto:pgsql-admin@postgresql.org>>; pgsql-admin@lists.postgresql.org<mailto:pgsql-admin@lists.postgresql.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.bhattacharjee@kpn.com<mailto:soumik.bhattacharjee@kpn.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.karandikar@gmail.com<mailto:siddharth.karandikar@gmail.com>>
Sent: donderdag 29 oktober 2020 10:33
To: Bhattacharjee, Soumik <soumik.bhattacharjee@kpn.com<mailto:soumik.bhattacharjee@kpn.com>>
Cc: pgsql-admin <pgsql-admin@postgresql.org<mailto:pgsql-admin@postgresql.org>>; pgsql-admin@lists.postgresql.org<mailto:pgsql-admin@lists.postgresql.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.bhattacharjee@kpn.com<mailto:soumik.bhattacharjee@kpn.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




^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* Re: TCP/IP connections refused
  2020-10-29 08:18 TCP/IP connections refused soumik.bhattacharjee@kpn.com
@ 2020-10-29 10:05 ` Sushant Pawar <sushantxp@gmail.com>
  2020-10-29 11:39   ` RE: TCP/IP connections refused soumik.bhattacharjee@kpn.com
  1 sibling, 1 reply; 9+ messages in thread

From: Sushant Pawar @ 2020-10-29 10:05 UTC (permalink / raw)
  To: soumik.bhattacharjee@kpn.com; +Cc: pgsql-admin; pgsql-admin@lists.postgresql.org

Hi,

You might have already checked but I would suggest checking that the IP
address in pg_hba.conf file is the same client IP for which you have
received the error. For eg. when the error is *Connection to
192.168.42.123:5432 <http://192.168.42.123:5432; refused. * I would add
192.168.42.123 in pg_hba file. This can be your application gateway which
may differ from the actual application server IP.

Please check if Postgres is accepting a connection on port 5432. It may
happen that postgresql.auto.conf may have a different port specified in it.
You can cross verify entries in the postmaster.pid file  for listen_address
and port number on which Postgres instance is accepting the connection.


Regards
Sushant

On Thu, Oct 29, 2020 at 1:48 PM <soumik.bhattacharjee@kpn.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            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*
>
>
>

^ permalink  raw  reply  [nested|flat] 9+ messages in thread

* RE: TCP/IP connections refused
  2020-10-29 08:18 TCP/IP connections refused soumik.bhattacharjee@kpn.com
  2020-10-29 10:05 ` Re: TCP/IP connections refused Sushant Pawar <sushantxp@gmail.com>
@ 2020-10-29 11:39   ` soumik.bhattacharjee@kpn.com
  0 siblings, 0 replies; 9+ messages in thread

From: soumik.bhattacharjee@kpn.com @ 2020-10-29 11:39 UTC (permalink / raw)
  To: sushantxp@gmail.com; +Cc: pgsql-admin; pgsql-admin@lists.postgresql.org

Yes Sushant, I added the Apps IP ranges in pg_hba and restarted the PG services.

Port is 5432 and also postgresql.auto.conf is having same port.

Contents of postmaster.pid
$ cat postmaster.pid
26802
/var/lib/postgresql/12/main
1603903729
5432
/var/run/postgresql
*
  5432001    229378
ready




From: Sushant Pawar <sushantxp@gmail.com>
Sent: donderdag 29 oktober 2020 11:05
To: Bhattacharjee, Soumik <soumik.bhattacharjee@kpn.com>
Cc: pgsql-admin@postgresql.org; pgsql-admin@lists.postgresql.org
Subject: Re: TCP/IP connections refused

Hi,

You might have already checked but I would suggest checking that the IP address in pg_hba.conf file is the same client IP for which you have received the error. For eg. when the error is Connection to 192.168.42.123:5432<http://192.168.42.123:5432; refused.  I would add 192.168.42.123 in pg_hba file. This can be your application gateway which may differ from the actual application server IP.

Please check if Postgres is accepting a connection on port 5432. It may happen that postgresql.auto.conf may have a different port specified in it. You can cross verify entries in the postmaster.pid file  for listen_address and port number on which Postgres instance is accepting the connection.


Regards
Sushant

On Thu, Oct 29, 2020 at 1:48 PM <soumik.bhattacharjee@kpn.com<mailto:soumik.bhattacharjee@kpn.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




^ permalink  raw  reply  [nested|flat] 9+ messages in thread


end of thread, other threads:[~2020-10-30 08:50 UTC | newest]

Thread overview: 9+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2020-10-29 08:18 TCP/IP connections refused soumik.bhattacharjee@kpn.com
2020-10-29 09:32 ` Siddharth Karandikar <siddharth.karandikar@gmail.com>
2020-10-29 10:19   ` soumik.bhattacharjee@kpn.com
2020-10-29 10:33     ` Siddharth Karandikar <siddharth.karandikar@gmail.com>
2020-10-29 11:45       ` soumik.bhattacharjee@kpn.com
2020-10-29 15:26         ` rammohan ganapavarapu <rammohanganap@gmail.com>
2020-10-30 08:50           ` soumik.bhattacharjee@kpn.com
2020-10-29 10:05 ` Sushant Pawar <sushantxp@gmail.com>
2020-10-29 11:39   ` soumik.bhattacharjee@kpn.com

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox