I'm learning OpenLayers, so I've got a local project set up in the "quickstart" way with npm, where the project is served from http://localhost:5173/ . I've got a QGIS Server running on http://localhost:8081/cgi-bin/qgis_mapserv.fcgi.exe which serves 3 WFS and one WMTS layers for my project. Straight away the project worked fine with the WFS vector layers. Then I tried to add the raster WMTS layer, named "population", with the capabilities approach copied from https://openlayers.org/en/latest/examples/wmts-layer-from-capabilities.html . There were no errors, just the raster tile layer didn't show up. I did some console logging which made it clear that OpenLayers thinks it 'has' that raster layer, it has no trouble logging the various layer properties. I went into the debugging 'network' tab, and found the requests somewhat surprising. First, the requests for the WFS layers looked as expected:


and so on. Equally, the capabilities request looked as expected:


But subsequently, many requests which looked like tile requests were directed at port 5173, looking like this:


This confuses me plenty since I think the role of node in this setup is purely as a dev/build server for the project's html and Javascript files, but that Openlayers itself runs entirely in the browser and there is no server side Javascript functionality?

Since my QGIS server which serves the WMTS tiles is on port 8081, I would have expected the requests to look something like


So why is OpenLayers requesting tiles from port 5173? Am I misunderstanding how OpenLayers is meant to work?

  • what address is inside the capabilities document returned to OpenLayers
    – Ian Turton
    Commented Sep 9, 2022 at 10:00
  • Doesn't contain an address (only for the schemas). Should it? I thought the assumption was that the capablities request/response is about services with the same address (but different paths)? Pasting the top here: <Capabilities xsi:schemaLocation="opengis.net/wmts/1.0 schemas.opengis.net/wmts/1.0/wmtsGetCapabilities_response.xsd" version="1.0.0"> <ows:ServiceIdentification> <ows:ServiceType>OGC WMTS</ows:ServiceType> <ows:ServiceTypeVersion>1.0.0</ows:ServiceTypeVersion> <ows:Title>worl Commented Sep 9, 2022 at 16:56
  • There should be endpoint addresses and or template URLs that tell clients where to make requests to
    – Ian Turton
    Commented Sep 9, 2022 at 17:18
  • Since I'm using QGIS Server I have to put the address in via the qgis project which I'm using. Under Project Properties, in the WMS, WMTS tabs, is a field 'Advertised URL', and in the layer properties, QGIS Server tab, is a field 'Data URL'. I tried all of them, inserting 'localhost:8081/cgi-bin/qgis_mapserv.fcgi.exe', afterwards restarting apache, but none of the changes made a URL show up in the capabilities response. Also wanted to mention that for debugging, I had used QGIS as a client of the WMTS tile layer, and QGIS had no trouble displaying it based on its capabilities. Commented Sep 9, 2022 at 17:43
  • Drats, I was trying to restart apache the wrong way. Now I'm getting the URL <ows:Operation name="GetTile"> <ows:DCP> <ows:HTTP> <ows:Get xlink:href="localhost:8081/cgi-bin/qgis_mapserv.fcgi.exe?"> <ows:Constraint name="GetEncoding"> <ows:AllowedValues> <ows:Value>KVP</ows:Value> </ows:AllowedValues> </ows:Constraint> </ows:Get> </ows:HTTP> </ows:DCP> </ows:Operation> Commented Sep 9, 2022 at 18:27

1 Answer 1


The answer was really in comments by Ian above. In my QGIS Server project, in properties, under the WMTS tab, in the field 'Advertised URL', I entered the url with the port and cgi param, 'http://localhost:8081/cgi-bin/qgis_mapserv.fcgi.exe'. This results in the relevant block in the capabilities response

<ows:Operation name="GetTile">
<ows:Get xlink:href="http://localhost:8081/cgi-bin/qgis_mapserv.fcgi.exe?">
<ows:Constraint name="GetEncoding">

Subsequently, OpenLayers was able to fetch the tiles...

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.