[OSM-dev] Can't connect to local PostgreSQL database with osmosis
Ævar Arnfjörð Bjarmason
avarab at gmail.com
Tue Jan 19 13:34:17 GMT 2010
I can't connect to postgresql database that I can connect to with
pgsql(1) with osmosis and I can't figure out why this is:
osmosis --read-xml-0.6 /var/www/osm.nix.is/latest/Iceland.osm.bz2
--write-apidb-0.6 populateCurrentTables=yes host="localhost"
database="osmistmp" user="osmistmp" password="osmistmp"
validateSchemaVersion=no
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)
[...]
Nothing shows up in postgresql's log which suggests that it really
can't reach the server, but with the psql tool I can talk to the
server over TCP just fine:
$ psql -h localhost -W -U osmistmp osmistmp
Password for user osmistmp:
[...]
osmistmp=>
And I'm not having some DNS issues where localhost isn't resolved
(I've also tried to tell it to connect to127.0.0.1):
$ dig +short localhost
127.0.0.1
This is what my pg_hba.conf is like:
$ egrep -v -e ^# -e ^$ /etc/postgresql/8.4/main/pg_hba.conf
local all postgres ident
local all all ident
host all all 127.0.0.1/32 md5
host all all ::1/128 md5
I added some debugging strings to DatabaseContext.java and found out
that it's getting the connection as:
newConnection =
DriverManager.getConnection("jdbc:postgresql://localhost/osmistmp",
"osmistmp", "osmistmp");
Which looks fine.
More information about the dev
mailing list