I've prepared an instance of PostGIS and MapServer on the same machine. I have loaded data into PostGIS and can view these features successfully in thick clients (ArcGIS Pro, QGIS).

My MapServer appears to be creating a successful WMS service with two layers. However, these two layers, called from PostGIS, are empty of any features. The same two layers were the features successfully confirmed to be in the PostGIS database, above. Nevertheless, my WMS layers from MapServer show up empty.

What am I missing?

My Mapfile: https://pastebin.com/tRTJKTxA

My ms_error.txt: https://pastebin.com/daJJMEkJ

My PostgreSQL log file: https://pastebin.com/EN2LzheE

My WMS Returns: https://pastebin.com/NR0W0Pg7

  • What does ogrinfo -so PG:"host=localhost dbname=postgis user=XXXXXXXX password=XXXXX port=5432" fy9_mirta_points show?
    – user30184
    Mar 1, 2021 at 21:08
  • And what GetMap request did you send? What do you get from the database with SELECT ST_Extent(wkb_geometry) FROM fy19_mirta_points?
    – user30184
    Mar 1, 2021 at 23:12
  • ogrinfo -so PG:"host=localhost dbname=postgis user=XXXXXXXX password=XXXXX port=5432" fy9_mirta_points yields INFO: Open of 'PG:host=localhost dbname=postgis user=XXXXXXXX password=XXXXX port=5432' using driver 'PostgreSQL' successful. FAILURE: Couldn't fetch requested layer fy19_mirta_points; ! Mar 17, 2021 at 21:35
  • SELECT ST_Extent(wkb_geometry) FROM fy19_mirta_points; yields: st_extent BOX(-167.987855033 13.3594268460001, 174.107140074 71.326194974) (1 row) Mar 17, 2021 at 21:40
  • 1
    It appears I needed to declare my SRID and my unique field, as follows: DATA "wkb_geometry from fy19_mirta_points using srid=4326 using unique ogc_fid". It was probably the need to explicitly declare the ogc_fid field as the unique field that was necessary. Mar 17, 2021 at 22:08

1 Answer 1


Earlier, I asked why my MapServer PostGIS implementation was producing a WMS service without any layers in it. The original question in detail is at the bottom of this summary.

The responses here and in other forums were quite helpful. It narrowed down the problem to about ten areas, which I dutifully examined as a checklist. Richard Greenwood's earliest suggestions happened to be the most helpful. He suggested to look at the Apache logs to see what requests QGIS or ArcGIS was sending to MapServer. I'm glad I did - they kept redirecting in the URL to a "wms.map" file at the root directory that didn't exist.

I then looked at my mapfile and lo and behold, I was the one redirecting it! I had taken example code from the Setup a Mapfile For Your WMS documentation and hadn't customized it to my implementation. The example code wasn't annotated so I didn't realize it included an example that required revision.

It was in the WMS Metadata of the mapfile, where: "wms_onlineresource" "http://localhost/cgi-bin/mapserv.exe?map=wms.map&?"

I changed it to point to the actual mapfile location: "wms_onlineresource" "http://localhost/cgi-bin/mapserv.exe?map=%2Fms4w%2Fapps%2Fsegis-demo%2Fmap-segis-demo.map&?"

Ironic as it was a line in the mapfile that redirected the run of the program away from itself.

  • On Thu, Jun 3, 2021 at 10:24 AM Rahkonen Jukka (MML) wrote: Hi, All Mapserver admins do that error every now and then. There is a configuration option in the QGIS WMS Connection editor “Ignore GetMap/GetTile/GetLegendGraphic URI reported in capabilities” that helps to access many misconfigured WMS servers. If you check that box the same base URL that is used for GetCapabilities is used also for other requests. Other clients may have similar configuration option, at least OpenJUMP does. -Jukka Rahkonen- Jun 3, 2021 at 16:26
  • Ignoring URLs in the GetCapabilities response, can help you get around misconfigured servers, but be aware that properly configured servers can use different URLs for different requests so don't check this option by default.
    – nmtoken
    Nov 3, 2021 at 12:43

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.