Bug#570914: libpg-java: Can't establish a database connection to localhost if it has an IPv6 address

v.nix.is debian-bug at v.nix.is
Mon Feb 22 07:34:44 UTC 2010


Package: libpg-java
Version: 8.4-701-1
Severity: important


When I try to connect to a valid database with a valid user/password
on localhost I get an error like this:
    
    org.openstreetmap.osmosis.core.OsmosisRuntimeException: Unable to
    establish a database connection.
                at org.openstreetmap.osmosis.core.apidb.common.DatabaseContext.getPostgresConnection(DatabaseContext.java:111)
                [...]
        Caused by: org.postgresql.util.PSQLException: The connection attempt failed.
                at org.postgresql.core.v3.ConnectionFactoryImpl.openConnectionImpl(ConnectionFactoryImpl.java:150)
                [...]
        Caused by: java.net.SocketException: Network is unreachable
                at java.net.PlainSocketImpl.socketConnect(Native Method)
                [...]

The reason is seemingly that the Java driver tries to connect to the
local IPv6 address for "localhost", here's what my localhost
configuration is like:
        
    $ sudo ifconfig lo
    lo        Link encap:Local Loopback
              inet addr:127.0.0.1  Mask:255.0.0.0
              inet6 addr: ::1/128 Scope:Host

If I then do:

    sysctl -w net.ipv6.conf.all.disable_ipv6=1

Which changes it to this:
    
    $ sudo ifconfig lo
    lo        Link encap:Local Loopback
              inet addr:127.0.0.1  Mask:255.0.0.0

I can connect successfully to the PostgreSQL database from Java.

-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (650, 'testing'), (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-x86_64-linode11 (SMP w/4 CPU cores)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages libpg-java depends on:
ii  sun-java6-jre [java2-runtime- 6-16-1     Sun Java(TM) Runtime Environment (

libpg-java recommends no packages.

Versions of packages libpg-java suggests:
pn  postgresql                    <none>     (no description available)

-- no debconf information





More information about the pkg-java-maintainers mailing list