JDBC Connection Errors

Started by Sam Nelsonover 14 years ago9 messagesgeneral
Jump to latest
#1Sam Nelson
samn@consistentstate.com

Hi list,

A client is hitting an issue with JDBC:
org.postgresql.util.PSQLException: Connection refused. Check that the
hostname and port are correct and that the postmaster is accepting
TCP/IP connections.

-pg_hba.conf is set to trust 0.0.0.0/0 (IPv4 only)
-listen_addresses is *
-I can find no evidence of iptables running on the server.
-PGAdmin connects just fine.
-psql connects just fine.
-I can find no errors in the log file from that day for the user that
the client is trying to log in as.

We're working on getting access to more details about how they're
trying to connect, but in the mean time, does anyone know if JDBC has
any issues connecting that psql and PGAdmin wouldn't have?  Is it
possible that JDBC is somehow susceptible to connection issues that
JDBC and psql are not?
---
===========================
Samuel Nelson
Consistent State
www.consistentstate.com
303-955-0509
===========================

#2Dave Cramer
pg@fastcrypt.com
In reply to: Sam Nelson (#1)
Re: JDBC Connection Errors

The only difference JDBC has over psql is that it has to connect via
tcpip. Not sure about pgadmin.

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca

Show quoted text

On Tue, Aug 23, 2011 at 6:47 PM, Sam Nelson <samn@consistentstate.com> wrote:

Hi list,

A client is hitting an issue with JDBC:
org.postgresql.util.PSQLException: Connection refused. Check that the
hostname and port are correct and that the postmaster is accepting
TCP/IP connections.

-pg_hba.conf is set to trust 0.0.0.0/0 (IPv4 only)
-listen_addresses is *
-I can find no evidence of iptables running on the server.
-PGAdmin connects just fine.
-psql connects just fine.
-I can find no errors in the log file from that day for the user that
the client is trying to log in as.

We're working on getting access to more details about how they're
trying to connect, but in the mean time, does anyone know if JDBC has
any issues connecting that psql and PGAdmin wouldn't have?  Is it
possible that JDBC is somehow susceptible to connection issues that
JDBC and psql are not?
---
===========================
Samuel Nelson
Consistent State
www.consistentstate.com
303-955-0509
===========================

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

#3Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Sam Nelson (#1)
Re: JDBC Connection Errors

On Tuesday, August 23, 2011 3:47:33 pm Sam Nelson wrote:

Hi list,

A client is hitting an issue with JDBC:
org.postgresql.util.PSQLException: Connection refused. Check that the
hostname and port are correct and that the postmaster is accepting
TCP/IP connections.

-pg_hba.conf is set to trust 0.0.0.0/0 (IPv4 only)
-listen_addresses is *
-I can find no evidence of iptables running on the server.
-PGAdmin connects just fine.
-psql connects just fine.

Are PgAdmin and psql local and the Java client remote?
Is the Java client connecting using IPv6 ?

-I can find no errors in the log file from that day for the user that
the client is trying to log in as.

We're working on getting access to more details about how they're
trying to connect, but in the mean time, does anyone know if JDBC has
any issues connecting that psql and PGAdmin wouldn't have? Is it
possible that JDBC is somehow susceptible to connection issues that
JDBC and psql are not?
---
===========================
Samuel Nelson
Consistent State
www.consistentstate.com
303-955-0509
===========================

--
Adrian Klaver
adrian.klaver@gmail.com

#4Sam Nelson
samn@consistentstate.com
In reply to: Adrian Klaver (#3)
Re: JDBC Connection Errors

Everything is remote. I thought of the IPv6 thing, but that seems
unlikely - all connections are coming from the same system.

Still, we'll ask them and try to get some more details about things like that.
---
===========================
Samuel Nelson
Consistent State
www.consistentstate.com
303-955-0509
===========================

Show quoted text

On Tue, Aug 23, 2011 at 5:46 PM, Adrian Klaver <adrian.klaver@gmail.com> wrote:

On Tuesday, August 23, 2011 3:47:33 pm Sam Nelson wrote:

Hi list,

A client is hitting an issue with JDBC:
org.postgresql.util.PSQLException: Connection refused. Check that the
hostname and port are correct and that the postmaster is accepting
TCP/IP connections.

-pg_hba.conf is set to trust 0.0.0.0/0 (IPv4 only)
-listen_addresses is *
-I can find no evidence of iptables running on the server.
-PGAdmin connects just fine.
-psql connects just fine.

Are PgAdmin and psql local and the Java client remote?
Is the Java client connecting using IPv6 ?

-I can find no errors in the log file from that day for the user that
the client is trying to log in as.

We're working on getting access to more details about how they're
trying to connect, but in the mean time, does anyone know if JDBC has
any issues connecting that psql and PGAdmin wouldn't have?  Is it
possible that JDBC is somehow susceptible to connection issues that
JDBC and psql are not?
---
===========================
Samuel Nelson
Consistent State
www.consistentstate.com
303-955-0509
===========================

--
Adrian Klaver
adrian.klaver@gmail.com

#5Adrian Klaver
adrian.klaver@aklaver.com
In reply to: Sam Nelson (#4)
Re: JDBC Connection Errors

On Tuesday, August 23, 2011 6:58:13 pm Sam Nelson wrote:

Everything is remote. I thought of the IPv6 thing, but that seems
unlikely - all connections are coming from the same system.

The easy way to test is to throw in an IPv6 rule that matches the IPv4 rule into
pg_hba.conf.

Still, we'll ask them and try to get some more details about things like
that. ---

--
Adrian Klaver
adrian.klaver@gmail.com

#6Guillaume Lelarge
guillaume@lelarge.info
In reply to: Dave Cramer (#2)
Re: JDBC Connection Errors

On Tue, 2011-08-23 at 19:38 -0400, Dave Cramer wrote:

The only difference JDBC has over psql is that it has to connect via
tcpip. Not sure about pgadmin.

pgAdmin is like psql on this. It can use TCP connections, and socket
connections.

--
Guillaume
http://blog.guillaume.lelarge.info
http://www.dalibo.com

#7Thomas Markus
t.markus@proventis.net
In reply to: Sam Nelson (#1)
Re: JDBC Connection Errors

Hi,

- check for open server socket: netstat -tulpen | grep postgres
- try to force ipv4 for java with system property (a recent jre prefers
ipv6): -Djava.net.preferIPv4Stack=true

regards
Thomas

Am 24.08.2011 00:47, schrieb Sam Nelson:

Show quoted text

Hi list,

A client is hitting an issue with JDBC:
org.postgresql.util.PSQLException: Connection refused. Check that the
hostname and port are correct and that the postmaster is accepting
TCP/IP connections.

-pg_hba.conf is set to trust 0.0.0.0/0 (IPv4 only)
-listen_addresses is *
-I can find no evidence of iptables running on the server.
-PGAdmin connects just fine.
-psql connects just fine.
-I can find no errors in the log file from that day for the user that
the client is trying to log in as.

We're working on getting access to more details about how they're
trying to connect, but in the mean time, does anyone know if JDBC has
any issues connecting that psql and PGAdmin wouldn't have? Is it
possible that JDBC is somehow susceptible to connection issues that
JDBC and psql are not?
---
===========================
Samuel Nelson
Consistent State
www.consistentstate.com
303-955-0509
===========================

#8Craig Ringer
craig@2ndquadrant.com
In reply to: Sam Nelson (#1)
Re: JDBC Connection Errors

On 24/08/2011 6:47 AM, Sam Nelson wrote:

Hi list,

A client is hitting an issue with JDBC:
org.postgresql.util.PSQLException: Connection refused. Check that the
hostname and port are correct and that the postmaster is accepting
TCP/IP connections.

-pg_hba.conf is set to trust 0.0.0.0/0 (IPv4 only)
-listen_addresses is *
-I can find no evidence of iptables running on the server.
-PGAdmin connects just fine.
-psql connects just fine.
-I can find no errors in the log file from that day for the user that
the client is trying to log in as.

Get them to run Wireshark and capture the connection attempt, then send
you the pcap log. That should give you more information about what's
actually happening.

Check for possible SELinux involvement if the Java client is on Linux.

--
Craig Ringer

#9Ian Pilcher
arequipeno@gmail.com
In reply to: Craig Ringer (#8)
Re: JDBC Connection Errors

On 08/28/2011 08:33 AM, Craig Ringer wrote:

A client is hitting an issue with JDBC:
org.postgresql.util.PSQLException: Connection refused. Check that the
hostname and port are correct and that the postmaster is accepting
TCP/IP connections.

-pg_hba.conf is set to trust 0.0.0.0/0 (IPv4 only)

Does it work with -Djava.net.preferIPv4Stack=true is specified on the
client command line (or if the property is otherwise set)? If so, the
problem is that many JVMs default to using IPv6 if available.

--
========================================================================
Ian Pilcher arequipeno@gmail.com
"If you're going to shift my paradigm ... at least buy me dinner first."
========================================================================