serve
qgis-cli serve
Starts an HTTP server that exposes a project over WMS, WFS, OGC API, and XYZ tiles. The project is loaded once and shared by the worker pool.
Synopsis
qgis-cli serve <PROJECT> [OPTIONS]qgis-cli serve --projects-dir <DIR> [OPTIONS]Options
| Option | Default | Description |
|---|---|---|
--port <PORT> | 8080 | Port to listen on. |
--host <ADDR> | 127.0.0.1 | Bind address. Use 0.0.0.0 to accept external connections. |
--workers <N> | number of CPUs | Render workers. QGIS is single-threaded per worker. |
--cache <SIZE> | 256mb | Tile cache size, e.g. 512mb. Add --cache-dir for a disk tier. |
--cache-dir <DIR> | — | Disk-backed second tier for the tile cache. |
--cache-ttl <SECS> | 3600 | Cache entry lifetime. |
--auth-key <KEY> | — | Require this API key. Repeatable. |
--anonymous | off | Allow unauthenticated reads alongside API keys. |
--rate-limit <N> | unlimited | Requests per minute per key. |
--projects-dir <DIR> | — | Serve every project in a directory, routed by name. |
Endpoints
GET / Landing page (JSON)GET /health Health check
GET /wms?SERVICE=WMS&REQUEST=GetCapabilities WMS 1.3GET /wms?SERVICE=WMS&REQUEST=GetMap&... WMS 1.3 map imageGET /wms?SERVICE=WMS&REQUEST=GetFeatureInfo WMS 1.3 attribute query
GET /wfs?SERVICE=WFS&REQUEST=GetCapabilities WFS 1.1GET /wfs?SERVICE=WFS&REQUEST=GetFeature&... WFS 1.1 features
GET /tiles/{z}/{x}/{y}.png XYZ tileGET /tiles/{z}/{x}/{y}@2x.png Retina tile (512px)
GET /collections OGC API FeaturesGET /collections/{id}/items GeoJSON featuresGET /map OGC API MapsExamples
# Single projectqgis-cli serve map.qgs --port 8080
# Production-ish settingsqgis-cli serve map.qgs --host 0.0.0.0 --port 8080 \ --workers 4 --cache 512mb --cache-dir ./cache/ \ --auth-key my-secret-key --rate-limit 100
# Every project in a directoryqgis-cli serve --projects-dir ./maps/ --port 8080With --projects-dir, each project is mounted under its file name:
/berlin/wms, /berlin/tiles/{z}/{x}/{y}.png, /paris/collections, and so on.
Try it
# Capabilitiescurl 'http://localhost:8080/wms?SERVICE=WMS&REQUEST=GetCapabilities'
# A 512x512 map imagecurl -o map.png 'http://localhost:8080/map?bbox=13.3,52.4,13.5,52.6&width=512&height=512'
# GeoJSON featurescurl 'http://localhost:8080/collections/buildings/items?limit=2'See also
- Server Overview — architecture and protocol coverage
servermodule — embed the server in your own binarywmsandwfs— protocol detailsqgis-cli tiles— pre-render instead of rendering on request