Skip to content

QGIS Server won't render VRT in WMS requests #64733

Description

@NivGreenstein

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

  1. build the docker image
  2. download the qgis project
  3. edit docker compose to your local setup
  4. Extract and open StatisticsTestVRT.qgz and add to it test.vrt
  5. 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.
  6. 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'
  1. see logs

On QGIS Desktop it works as expected

Project
qgis_vrt_sample.zip

Image

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 version3.44.7-Solothurn
QGIS code revisionea262bc5ed8
 
Libraries
Qt version5.15.3
Python version3.10.12
GDAL version3.4.1
PROJ version8.2.1
EPSG Registry database versionv10.041 (2021-12-03)
GEOS version3.10.2-CAPI-1.16.0
SQLite version3.37.2
PDAL version2.3.0
PostgreSQL client version14.20
SpatiaLite version5.0.1
QWT version6.1.4
QScintilla2 version2.11.6
OS versionUbuntu 22.04.5 LTS
 
Active Python plugins
MetaSearch0.3.6
grassprovider2.12.99
processing2.12.99
db_manager0.1.20

Supported QGIS version

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

New profile

Additional context

No response

Metadata

Metadata

Assignees

Labels

BugEither a bug report, or a bug fix. Let's hope for the latter!ServerRelated to QGIS server

Type

No type
No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions