Skip to content

DuckDB Extension

HTTP Server

Serve SQL queries over HTTP from a running DuckDB process. Start a local endpoint, authenticate requests, and return query results as JSON.

48,937
extension loads · last 90 days
On this page

Let an HTTP client query a running DuckDB database

HTTP Server starts a listener inside DuckDB. Clients submit SQL over HTTP and receive JSON results, giving scripts or an internal application access to an existing DuckDB session without a database client library.

The serving process must remain running. Choose which database and connection state it exposes, and configure authentication before giving other clients access. A read-only database is useful when the endpoint should serve queries without accepting changes.

Example

Start a local SQL endpoint

Run the SQL in an interactive DuckDB session, keep it open, and send the curl request from a second terminal.

Before you run it: Use a native DuckDB session and a free local port 9999. The process must remain running while you make the HTTP request.

Run this example in the DuckDB CLI or a native client.

SET allow_extension_repositories = 'allowed';
CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
  WITH PREFIX 'https://duckdb-extensions.query.farm';
INSTALL httpserver FROM query_farm;
LOAD httpserver FROM query_farm;

-- Demo credentials: change these before using your own data.
SELECT httpserve_start('127.0.0.1', 9999, 'demo:change-me');

-- In another terminal:
-- curl --user 'demo:change-me' --data 'SELECT 42 AS answer' \
--   http://127.0.0.1:9999/

-- After trying the request, stop the server with:
-- SELECT httpserve_stop();

The endpoint executes SQL in this DuckDB process. The loopback address keeps this example local. See the read-only database recipe before serving data to other clients.

Common tasks

Deep Dive

Technical Details

Reference

Extension Contents

Quick reference to all available functions and settings organized by category.

Configuration
httpserver_allow_unauthenticated_remote Object type: Setting Allow httpserve_start to listen on a non-loopback address without an auth credential, letting anyone who can reach it run any SQL.
httpserver_allowed_origins Object type: Setting Comma-separated origins (e.g.
httpserver_tls_cert Object type: Setting Path to a PEM certificate (chain); with httpserver_tls_key set, httpserve_start serves HTTPS.
httpserver_tls_key Object type: Setting Path to the PEM private key for httpserver_tls_cert.
Server
httpserve_start() Object type: Scalar function Start the embedded HTTP query server for the current database.
httpserve_stop() Object type: Scalar function Stop the current database's HTTP server, closing the listening socket and waiting for in-flight requests to finish.

API Reference

Function Reference

Configuration

Settings

Configure the http server extension behavior using these settings.

httpserver_allow_unauthenticated_remote

Default Value: false

httpserver_allowed_origins

Default Value: —

httpserver_tls_cert

Default Value: —

httpserver_tls_key

Default Value: —

Practical Examples

Cookbook

Real-world recipes and patterns for common use cases.

Platform Support

Compatibility

Extension availability may vary by platform and DuckDB version. Check below to ensure this extension supports your environment before installation.

Quick Facts

Release status Stable
Software License MIT
Pricing Free
Written In C++
Source Available Yes
View on GitHub
Usage
48,937
loads · last 90 days

Platforms

DuckDB 2.0.0

  • Linux x86_64aarch64
  • Linux (musl) Not available
  • macOS Apple Silicon
  • Windows x86_64x86_64 (MinGW)
  • WASM Not available
Compiled binary sizes
Platform Architecture Size
Linux x86_64 17.71 MB
Linux aarch64 15.67 MB
macOS Apple Silicon 13.18 MB
Windows x86_64 11.84 MB
Windows x86_64 (MinGW) 20.54 MB

Compressed download sizes for the release shown above.

DuckDB & Haybarn

Release calendar
  • DuckDB v2.0.0 Query.Farm repository Supported

Browser examples use Haybarn-Wasm 2.0.0-rc12.

Checked .

Learn and explore

Tutorials and articles

Writing about HTTP Server: how it works, what changed, and why.