Environment - Windows10(x64), PostgreSQL 9.5(x64)

I installed GDAL, PROJ.4 and GEOS (via OSGeo4W )

Then I installed postGIS via Stack App Builder (I have tried both versions - x32 and x64). In both cases I have the same error - Error: couldn't load library C:/Program Files/PostgreSQL/9.5/lib/postgis-2.2.dll: %1 is not a valid Win32 application

I went to ../lib/ and postgis-2.2.dll is present there.

But when I am entering in psql shell - CREATE EXTENSION postgis; - I get this error.

  • You can try (based on 32/64 bit) from download.osgeo.org/postgis/windows and it will definitely work..some times Stack App builder is not work (may be due to some internal errors)
    – Sunil
    Commented Jun 8, 2016 at 13:16

1 Answer 1


Not sure what you mean by installed GDAL, PROJ.4, and GEOS via OSGeo4W. PostGIS already comes packaged with those and (ones in stackbuilder and download.osgeo.org page is not compatible with OSGEO4W packaged ones). So if you are copying the ones you got in OSGeo4W into your PostgreSQL folder, it won't work.

Also make sure you use 64-bit postgis with 64-bit PostgreSQL and 32-bit postgis with 32-bit PostgreSQL. On windows you'll see both in stackbuilder because you can run 32-bit PostgreSQL on 32-bit windows.

One last thing, if you already messed things up you need to overwrite the libxml2-2.dll with the libxml2.dll that came with PostgreSQL (just copy it and rename it). The installer will only create these if they don't exist but will not overwrite them and if you made the mistake of using 32-bit installer, you have a 32-bit libxml2-2.dll.

  • Thank you so much - my hero!
    – cs94njw
    Commented Aug 27, 2019 at 19:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.