Hi 👋
I’m running a local, containerized QGIS Server and trying to serve a project via WMS that includes a VRT layer.
When sending a WMS request, QGIS Server consistently responds with HTTP 500 - Internal Server Error.
According to the QGIS logs, the failure seems related to GDAL VRT Python support. The log explicitly says:
You can set the GDAL_VRT_ENABLE_PYTHON configuration option to YES
I’ve already set GDAL_VRT_ENABLE_PYTHON=YES (see Dockerfile below), but the issue persists and the VRT still fails to load.
I’ve attached:
The Dockerfile used to build the QGIS Server image
Relevant QGIS Server logs showing the error
Has anyone encountered this before, or can point out what I might be missing (additional env vars, build flags, runtime configuration, etc.)?
Thanks in advance
QGIS Server WMS Request Logs
2026-01-28 14:50:50 "Host" : "localhost:8088"
2026-01-28 14:50:50 "User-Agent" : "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36"
2026-01-28 14:50:50 12:50:50 INFO Server[21]: BBOX:95.04395557197803157,-57.09065890782964914,142.2939558344780266,0.0000009999999999999999547
2026-01-28 14:50:50 12:50:50 INFO Server[21]: CRS:CRS:84
2026-01-28 14:50:50 12:50:50 INFO Server[21]: DPI:96
2026-01-28 14:50:50 12:50:50 INFO Server[21]: FORMAT:image/png
2026-01-28 14:50:50 12:50:50 INFO Server[21]: FORMAT_OPTIONS:dpi:96
2026-01-28 14:50:50 12:50:50 INFO Server[21]: HEIGHT:770
2026-01-28 14:50:50 12:50:50 INFO Server[21]: LAYERS:test
2026-01-28 14:50:50 12:50:50 INFO Server[21]: MAP_RESOLUTION:96
2026-01-28 14:50:50 12:50:50 INFO Server[21]: REQUEST:GetMap
2026-01-28 14:50:50 12:50:50 INFO Server[21]: SERVICE:WMS
2026-01-28 14:50:50 12:50:50 INFO Server[21]: STYLES:
2026-01-28 14:50:50 12:50:50 INFO Server[21]: TRANSPARENT:TRUE
2026-01-28 14:50:50 12:50:50 INFO Server[21]: VERSION:1.3.0
2026-01-28 14:50:50 12:50:50 INFO Server[21]: WIDTH:638
2026-01-28 14:50:50 12:50:50 INFO Server[21]: WMS Request parameters:
2026-01-28 14:50:50 12:50:50 INFO Server[21]: - CRS : CRS:84
2026-01-28 14:50:50 12:50:50 INFO Server[21]: - WIDTH : 638
2026-01-28 14:50:50 12:50:50 INFO Server[21]: - HEIGHT : 770
2026-01-28 14:50:50 12:50:50 INFO Server[21]: - BBOX : 95.04395557197803157,-57.09065890782964914,142.2939558344780266,0.0000009999999999999999547
2026-01-28 14:50:50 12:50:50 INFO Server[21]: - LAYERS : test
2026-01-28 14:50:50 12:50:50 INFO Server[21]: - FORMAT : image/png
2026-01-28 14:50:50 12:50:50 INFO Server[21]: - TRANSPARENT : TRUE
2026-01-28 14:50:50 12:50:50 INFO Server[21]: - DPI : 96
2026-01-28 14:50:50 12:50:50 INFO Server[21]: - FORMAT_OPTIONS : dpi:96
2026-01-28 14:50:50 12:50:50 INFO Server[21]: - VERSION : 1.3.0
2026-01-28 14:50:50 12:50:50 INFO server[21]: Parallel rendering deactivated
2026-01-28 14:50:50 ERROR 1: Python code needs to be executed, but it uses online code in the VRT whereas the current policy is to trust only code from external trusted modules (defined in the GDAL_VRT_PYTHON_TRUSTED_MODULES configuration option). If you trust the code in /mnt/test.vrt, you can set the GDAL_VRT_ENABLE_PYTHON configuration option to YES.
2026-01-28 14:50:50 Logged warning: RasterIO error: Python code needs to be executed, but it uses online code in the VRT whereas the current policy is to trust only code from external trusted modules (defined in the GDAL_VRT_PYTHON_TRUSTED_MODULES configuration option). If you trust the code in /mnt/test.vrt, you can set the GDAL_VRT_ENABLE_PYTHON configuration option to YES.
2026-01-28 14:50:50 QPaintDevice: Cannot destroy paint device that is being painted
2026-01-28 14:50:50 12:50:50 CRITICAL Server[21]: Rendering error : 'Python code needs to be executed, but it uses online code in the VRT whereas the current policy is to trust only code from external trusted modules (defined in the GDAL_VRT_PYTHON_TRUSTED_MODULES configuration option). If you trust the code in /mnt/test.vrt, you can set the GDAL_VRT_ENABLE_PYTHON configuration option to YES.' in layer 'test'
2026-01-28 14:50:50 12:50:50 WARNING FCGIServer[21]: finish() called twice
2026-01-28 14:50:50 12:50:50 INFO Server[21]: Request finished in 132 ms
Verify that GDAL_VRT_ENABLE_PYTHON is YES
$ echo $GDAL_VRT_ENABLE_PYTHON
YES
Dockerfile
FROM debian:bookworm-slim AS base
ENV LANG=en_EN.UTF-8
RUN apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests --allow-unauthenticated -y \
gnupg \
ca-certificates \
wget \
locales \
&& localedef -i en_US -f UTF-8 en_US.UTF-8 \
&& mkdir -m755 -p /etc/apt/keyrings \
&& wget -O /etc/apt/keyrings/qgis-archive-keyring.gpg https://download.qgis.org/downloads/qgis-archive-keyring.gpg \
&& echo "deb [signed-by=/etc/apt/keyrings/qgis-archive-keyring.gpg] https://qgis.org/debian bookworm main" | tee /etc/apt/sources.list.d/qgis.list \
&& apt-get update \
&& apt-get install --no-install-recommends --no-install-suggests --allow-unauthenticated -y \
qgis-server \
spawn-fcgi \
xauth \
xvfb \
python3-scipy \
&& apt-get remove --purge -y \
gnupg \
wget \
&& rm -rf /var/lib/apt/lists/*
RUN useradd -m qgis
ENV TINI_VERSION v0.19.0
ADD https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini /tini
RUN chmod +x /tini
ENV QGIS_PREFIX_PATH /usr
ENV QGIS_SERVER_LOG_STDERR 1
ENV QGIS_SERVER_LOG_LEVEL 2
COPY cmd.sh /home/qgis/cmd.sh
RUN chmod -R 777 /home/qgis/cmd.sh
RUN chown qgis:qgis /home/qgis/cmd.sh
USER qgis
WORKDIR /home/qgis
ENTRYPOINT ["/tini", "--"]
CMD ["/home/qgis/cmd.sh"]
FROM base
USER root
RUN apt-get update
RUN apt-get install -y linux-perf htop
USER qgis
cmd.sh
#!/bin/bash
set -e
[[ "$DEBUG" == "1" ]] && env
exec /usr/bin/xvfb-run --auto-servernum --server-num=1 /usr/bin/spawn-fcgi -p 5555 -n -d /home/qgis -- /usr/lib/cgi-bin/qgis_mapserv.fcgi
docker-compose
version: '3.7'
services:
qgis-server:
# Should use version with utf-8 locale support:
image: qgis-server:local
container_name: qgis-server
privileged: true
volumes:
- /tmp/vrt_sample:/mnt
environment:
- DEBUG=1 # display env before spawning QGIS Server
- LANG=en_EN.UTF-8
- QGIS_SERVER_PARALLEL_RENDERING=0
- QGIS_SERVER_FORCE_READONLY_LAYERS=false
- QGIS_SERVER_MAX_THREADS=8
- QGIS_PROJECT_FILE=/mnt/StatisticsTestVRT.qgz
- QGIS_SERVER_LOG_LEVEL=0 # 0: INFO, 1: WARNING, 2: CRITICAL
- QGIS_SERVER_LOG_PROFILE=true
- QGIS_SERVER_PROJECT_CACHE_STRATEGY=off
- GDAL_VRT_ENABLE_PYTHON=YES
- CPL_DEBUG=ON
- GDAL_DEBUG=VRT
nginx:
image: nginx:1.13
container_name: nginx
ports:
- 8088:80
volumes:
- ./nginx.conf:/etc/nginx/conf.d/default.conf:ro
depends_on:
- qgis-server
Steps to reproduce the issue
- build the docker image
- download the qgis project
- edit docker compose to your local setup
- Extract and open
StatisticsTestVRT.qgz and add to it test.vrt
- Verify you can see the VRT like the image below. If it doesn't work - make sure to set
GDAL_VRT_ENABLE_PYTHON env to YES.
- Try to request WMS images
curl example
curl --location 'http://localhost:8088/qgis-server?SERVICE=WMS&VERSION=1.3.0&REQUEST=GetMap&BBOX=95.04395557197803157%2C-57.09065890782964914%2C142.2939558344780266%2C0.0000009999999999999999547&CRS=CRS%3A84&WIDTH=638&HEIGHT=770&LAYERS=test&STYLES=&FORMAT=image%2Fpng&DPI=96&MAP_RESOLUTION=96&FORMAT_OPTIONS=dpi%3A96&TRANSPARENT=TRUE'
- see logs
On QGIS Desktop it works as expected
Project
qgis_vrt_sample.zip
Versions
QGIS Server version
$ /usr/lib/cgi-bin/qgis_mapserv.fcgi --version
QGIS 3.44.7-Solothurn 'Solothurn' (ea262bc5ed8)
QGIS code revision ea262bc5ed8
Qt version 5.15.8
Python version 3.11.2
GDAL/OGR version 3.6.2
PROJ version 9.1.1
EPSG Registry database version v10.076 (2022-08-31)
GEOS version 3.11.1-CAPI-1.17.1
SQLite version 3.40.1
OS Debian GNU/Linux 12 (bookworm)
QGIS Desktop version
| QGIS version | 3.44.7-Solothurn |
| QGIS code revision | ea262bc5ed8 |
| |
| Libraries |
| Qt version | 5.15.3 |
| Python version | 3.10.12 |
| GDAL version | 3.4.1 |
| PROJ version | 8.2.1 |
| EPSG Registry database version | v10.041 (2021-12-03) |
| GEOS version | 3.10.2-CAPI-1.16.0 |
| SQLite version | 3.37.2 |
| PDAL version | 2.3.0 |
| PostgreSQL client version | 14.20 |
| SpatiaLite version | 5.0.1 |
| QWT version | 6.1.4 |
| QScintilla2 version | 2.11.6 |
| OS version | Ubuntu 22.04.5 LTS |
| |
| Active Python plugins |
| MetaSearch | 0.3.6 |
| grassprovider | 2.12.99 |
| processing | 2.12.99 |
| db_manager | 0.1.20 |
Supported QGIS version
New profile
Additional context
No response
Hi 👋
I’m running a local, containerized QGIS Server and trying to serve a project via WMS that includes a VRT layer.
When sending a WMS request, QGIS Server consistently responds with HTTP 500 - Internal Server Error.
According to the QGIS logs, the failure seems related to GDAL VRT Python support. The log explicitly says:
I’ve already set
GDAL_VRT_ENABLE_PYTHON=YES(see Dockerfile below), but the issue persists and the VRT still fails to load.I’ve attached:
The Dockerfile used to build the QGIS Server image
Relevant QGIS Server logs showing the error
Has anyone encountered this before, or can point out what I might be missing (additional env vars, build flags, runtime configuration, etc.)?
Thanks in advance
QGIS Server WMS Request Logs
Verify that
GDAL_VRT_ENABLE_PYTHONisYESDockerfile
cmd.sh
docker-compose
Steps to reproduce the issue
StatisticsTestVRT.qgzand add to ittest.vrtGDAL_VRT_ENABLE_PYTHONenv toYES.curl example
On QGIS Desktop it works as expected
Project
qgis_vrt_sample.zip
Versions
QGIS Server version
$ /usr/lib/cgi-bin/qgis_mapserv.fcgi --version QGIS 3.44.7-Solothurn 'Solothurn' (ea262bc5ed8) QGIS code revision ea262bc5ed8 Qt version 5.15.8 Python version 3.11.2 GDAL/OGR version 3.6.2 PROJ version 9.1.1 EPSG Registry database version v10.076 (2022-08-31) GEOS version 3.11.1-CAPI-1.17.1 SQLite version 3.40.1 OS Debian GNU/Linux 12 (bookworm)QGIS Desktop version
Supported QGIS version
New profile
Additional context
No response