pg.ddx.io  pgsql-admin@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: soumik.bhattacharjee@kpn.com
To: sushantxp@gmail.com
Cc: pgsql-admin@postgresql.org
Cc: pgsql-admin@lists.postgresql.org
Subject: RE: TCP/IP connections refused
Date: Thu, 29 Oct 2020 11:39:58 +0000
Message-ID: <7d2987e1a37846289f0e514400ca92e6@kpn.com> (raw)
In-Reply-To: <CAF2=t-qOzo9eYR1cYVJxFFG+iQAo=aA62L3iFbSGgrys9bD5aw@mail.gmail.com>
References: <36b20ed42da4410d9ddd1b1bd0140d41@kpn.com>
	<CAF2=t-qOzo9eYR1cYVJxFFG+iQAo=aA62L3iFbSGgrys9bD5aw@mail.gmail.com>

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




view thread (9+ messages)  latest in thread

Message-ID: <7d2987e1a37846289f0e514400ca92e6@kpn.com>
Permalink:  ../7d2987e1a37846289f0e514400ca92e6@kpn.com/
Also on:    postgresql.org/message-id/7d2987e1a37846289f0e514400ca92e6@kpn.com

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-admin@postgresql.org
  Cc: soumik.bhattacharjee@kpn.com, sushantxp@gmail.com, pgsql-admin@lists.postgresql.org
  Subject: RE: TCP/IP connections refused
  In-Reply-To: <7d2987e1a37846289f0e514400ca92e6@kpn.com>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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