#62608·QGIS

QGIS Server Layer(s) not valid Exception with multiple projects using same WMS Layer

Author: rsrg-zwiamaCreated Jul 17, 2025Updated Sep 18, 2026
LabelsRegressionBugServer

What is the bug or the crash?

Using QGIS Server I get a <ServerException>Layer(s) not valid</ServerException> error, although the layer is ok. It only occurs once in a setup, where more than one .qgs projects use the same WMS source as layer. Requests to the projects works for the 1st project called, but not for the 2nd. Exact way to reproduce see in section below.

Steps to reproduce the issue

  1. create several QGIS project files containing the same WMS sources as layers. For example qgis1.qgs with layer 1
URL	https://wms.geo.admin.ch/?VERSION=1.3.0
Source	 contextualWMSLegend=0&crs=EPSG:2056&dpiMode=7&featureCount=10&format=image/jpeg&layers=ch.swisstopo.pixelkarte-grau&styles&tilePixelRatio=0&url=https://wms.geo.admin.ch/?VERSION%3D1.3.0

and layer 2

URL	https://sgx.geodatenzentrum.de/wms_topplus_open
Source	contextualWMSLegend=0&crs=EPSG:3857&dpiMode=7&featureCount=10&format=image/png&layers=web_grau&styles&tilePixelRatio=0&url=https://sgx.geodatenzentrum.de/wms_topplus_open
  1. repeat step 1 for 2 to 4 more projects qgis2, qgis3 etc with identical content.
  2. serve the projects to QGIS server (data folder). I do this via docker compose like here: https://github.com/qgis/qgis-docker/blob/main/docker-compose.yml
  3. in docker curl "localhost/ogc/qgis1?SERVICE=WMS&REQUEST=GetCapabilities" -> works fine
  4. curl "localhost/ogc/qgis2?SERVICE=WMS&REQUEST=GetCapabilities" -> layer not valid
  5. curl "localhost/ogc/qgis3?SERVICE=WMS&REQUEST=GetCapabilities" -> works fine

I can change the order of the request with the result, that always the project I request as second will fail. But only once. So I can do:

  1. curl "localhost/ogc/qgis2?SERVICE=WMS&REQUEST=GetCapabilities" -> works fine
  2. curl "localhost/ogc/qgis1?SERVICE=WMS&REQUEST=GetCapabilities" -> layer not valid
  3. curl "localhost/ogc/qgis1?SERVICE=WMS&REQUEST=GetCapabilities" -> works fine

Or:

  1. curl "localhost/ogc/qgis3?SERVICE=WMS&REQUEST=GetCapabilities" -> works fine
  2. curl "localhost/ogc/qgis1?SERVICE=WMS&REQUEST=GetCapabilities" -> layer not valid
  3. curl "localhost/ogc/qgis2?SERVICE=WMS&REQUEST=GetCapabilities" -> works fine
  4. curl "localhost/ogc/qgis1?SERVICE=WMS&REQUEST=GetCapabilities" -> works fine

It can be reproduced when only one layer is in the projects. QGIS Server must be restartet, to get the invalid layer again. So there is maybe some issue with cache?

Versions

I tested with the following docker images, which all result in layer not valid error:

  • 3.40
  • 3.40.1
  • 3.40-jammy
  • 3.40-bookworm
  • 3.42
  • 3.44 It works fine in 3.38 and 3.34

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

Additional context

No response