Thread: JDBC Connection Errors

JDBC Connection Errors

From
Sam Nelson
Date:
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
===========================

Re: JDBC Connection Errors

From
Dave Cramer
Date:
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




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
>

Re: JDBC Connection Errors

From
Adrian Klaver
Date:
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

Re: JDBC Connection Errors

From
Adrian Klaver
Date:
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

Re: JDBC Connection Errors

From
Sam Nelson
Date:
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
===========================



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
>

Re: JDBC Connection Errors

From
Guillaume Lelarge
Date:
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


Re: JDBC Connection Errors

From
Thomas Markus
Date:
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:
> 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
> ===========================
>

Re: JDBC Connection Errors

From
Craig Ringer
Date:
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

Re: JDBC Connection Errors

From
Ian Pilcher
Date:
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."
========================================================================