I can't get osm2pgsql to work on Windows, though I have the same import process working on wsl.

I have installed Windows postgresql (13.2.2) and osm2pgsql (1.4.2) using defaults mostly; pgadmin4 can see the postgresql databases and I can talk to postgres from psql (using defaults of localhost, postgres, 5433, postgres and the password). I am running osm2pgsql with

 osm2pgsql.exe -c -d gis -U postgres -W -H localhost -P 5433 -S "C:\Dev\2021\Carto\openstreetmap-carto.style" "C:\Temp\england-latest.osm.pbf"

and have tried every combination of parameters:

  • the above gives ERROR: Connecting to database failed: FATAL: password authentication failed for user "postgres"
  • if I omit the P 5433 (which matches the port number in postgresql.conf), I get Is the server running on host "localhost" (::1) and accepting TCP/IP connections on port 5432?
  • if I omit the -W, I get ERROR: Connecting to database failed: fe_sendauth: no password supplied

I never get asked for a password, ie, the -W appears not to behave as documented.

Is this a bug? Is there a workround? Or have I just got it wrong (very possible!)

asked 14 May, 10:32

ANDREW's gravatar image

ANDREW
11112
accept rate: 0%


Postgres authentication is often a bit fiddly even on Unix. You are right, it sounds like the -W does not behave as advertised. One thing that might help as a workaround is creating a database user with the same name as your Windows account (and making that account the owner of the gis database OR give that account postgres superuser rights). The pg_hba.conf which controls authentication should normally let you in without a password if you are the same user on the system that you try to connect to in postgres. Although I am worried by the "fe_sendauth: no password supplied" which, I believe, is issued by the client library and not the server, which would then of course mean that password-less login will never work because the client doesn't even try to connect.

permanent link

answered 14 May, 11:11

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
77.7k886901201
accept rate: 24%

Thanks, but as you suspected. Creating a database user with the same name as the Windows user results in the same behaviour: without the -W option, I get "fe_sendauth: no password supplied" and with the -W option: "password authentication failed" and without any chance of actually entering a password.

(14 May, 15:05) ANDREW

First: You should probably not use the "postgres" database user for day-to-day work, because it has superuser privileges.

I don't know why the "-W" doesn't work in your case. I just checked on Linux and it does work there. It might well be that it doesn't work on Windows for some reason, but none of the developers have a Windows machine to check. Instead of the command line options you can use environment variables to specify how to access the database. See the docs here: https://www.postgresql.org/docs/current/libpq-envars.html

permanent link

answered 14 May, 14:20

Jochen%20Topf's gravatar image

Jochen Topf
4.8k54769
accept rate: 30%

Thank you, using environment variables does get round the problem.

(14 May, 15:40) ANDREW
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×248
×187
×13

question asked: 14 May, 10:32

question was seen: 442 times

last updated: 14 May, 15:40

powered by OSQA