NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum

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\" "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 '21, 10:32

ANDREW's gravatar image

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 '21, 11:11

Frederik%20Ramm's gravatar image

Frederik Ramm ♦
accept rate: 23%

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 '21, 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:

permanent link

answered 14 May '21, 14:20

Jochen%20Topf's gravatar image

Jochen Topf
accept rate: 31%

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

(14 May '21, 15:40) ANDREW

Follow this question

By Email:

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



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "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:


question asked: 14 May '21, 10:32

question was seen: 2,573 times

last updated: 14 May '21, 15:40

NOTICE: is no longer in use from 1st March 2024. Please use the OpenStreetMap Community Forum