I am, trying to export GeoJSON from postgis. I am using the following code which is working local machine but when I am trying to use this in a server the following error is occuring


ogr2ogr -progress -f GeoJSON landuse_gen0.geojson -t_srs EPSG:4326 "PG:host=localhost port=5432 dbname=database user=usernbame password=Password" -sql "SELECT way, way_area AS area, COALESCE(landuse, leisure, 'natural', highway, amenity, tourism) AS type FROM planet_osm_polygon WHERE way_area > 100000 ORDER BY way_area DESC"


Unable to open datasource `PG:host=localhost port=5432 dbname=database user=usernbame password=Password' with the following drivers.
  -> `PCIDSK'
  -> `PDF'
  -> `ESRI Shapefile'
  -> `MapInfo File'
  -> `UK .NTF'
  -> `OGR_SDTS'
  -> `S57'
  -> `DGN'
  -> `OGR_VRT'
  -> `REC'
  -> `Memory'
  -> `BNA'
  -> `CSV'
  -> `GML'
  -> `GPX'
  -> `KML'
  -> `GeoJSON'
  -> `TopoJSON'
  -> `OGR_GMT'
  -> `WAsP'
  -> `OpenFileGDB'
  -> `XPlane'
  -> `DXF'
  -> `CAD'
  -> `Geoconcept'
  -> `GeoRSS'
  -> `GPSTrackMaker'
  -> `PGDUMP'
  -> `GPSBabel'
  -> `SUA'
  -> `OpenAir'
  -> `OGR_PDS'
  -> `HTF'
  -> `AeronavFAA'
  -> `EDIGEO'
  -> `SVG'
  -> `Idrisi'
  -> `ARCGEN'
  -> `SEGY'
  -> `ODS'
  -> `XLSX'
  -> `SXF'
  -> `Selafin'
  -> `JML'
  -> `VDV'
  -> `MVT'
  -> `TIGER'
  -> `AVCBin'
  -> `AVCE00'
  • 2
    Can you connect to the database using some other means, such as psql? Is is possible that you are trying to connect on an Internet socket, while the DB server is only listening on a Unix domain socket? Commented Jun 22, 2019 at 18:00
  • ST_AsGeoJSON works as well postgis.net/docs/ST_AsGeoJSON.html
    – Mapperz
    Commented Jun 22, 2019 at 22:32

1 Answer 1


It looks like the version of ogr2ogr you have on server was built without PostgreSQL support, or the postgres driver is not installed. Note that in the list of drivers there is no PostgreSQL, ogr2ogr just tries all existing drivers and none of them understands the connection string - this is what the error message means.

ogrinfo might provide better diagnostics.

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.