Skip to content

Enable HTTP/3 (QUIC) on nginx: build check, listen directives, Alt-Svc, and verification

A working nginx HTTP/3 setup: confirm your build has the v3 module, pair listen 443 quic reuseport with listen 443 ssl, send the Alt-Svc header browsers need, open UDP 443, and verify a real QUIC connection with curl.

Turning on HTTP/3 in nginx is not one directive, and that is why so many “enabled” servers still serve every byte over TCP. QUIC rides on UDP, so nginx needs a second listener on a protocol your firewall probably drops; the binary needs a module most distro packages leave out; and browsers will not touch HTTP/3 at all until an ordinary TCP response tells them it exists. By the end of this guide your server will be listening on 443/udp, advertising itself with an Alt-Svc header, and you will have a command that proves a real QUIC connection rather than a config file that merely looks correct.

What you’ll accomplish

  • Confirm whether your nginx binary was built with --with-http_v3_module, and know your options if it wasn’t.
  • Run the paired listen 443 quic reuseport; and listen 443 ssl; listeners on one server block without a reuseport conflict.
  • Emit the Alt-Svc response header that is the actual trigger for browser upgrades.
  • Open UDP/443 through the host firewall and any cloud security group in front of it.
  • Verify an end-to-end HTTP/3 request, including what to do when your curl cannot speak it.

Prerequisites

  • nginx 1.25.0 or newer. The quic listen parameter and the ngx_http_v3_module directives landed in 1.25.0; nothing in this guide works on 1.24 or the older quic preview branch, whose syntax differed.
  • A working HTTPS site with a valid certificate. HTTP/3 has no cleartext mode and mandates TLS 1.3, so get TCP TLS healthy first — see Nginx SSL with Let’s Encrypt if you are starting from nothing.
  • Root or sudo on the host, plus access to whatever filters traffic in front of it (cloud security group, on-prem firewall).
  • Be honest about your package: distro-shipped nginx frequently lacks the v3 module. Debian and Ubuntu’s nginx from the main archive, and RHEL/Alma’s nginx from AppStream, have historically been built without --with-http_v3_module. The official nginx.org mainline packages do include it. Check before you edit anything.
  • The TLS library matters for one specific feature. nginx builds QUIC against OpenSSL 1.1.1+ using a compatibility layer, and that layer does not provide TLS 1.3 0-RTT (early data). If you want 0-RTT you need OpenSSL 3.5.1 or newer, or a BoringSSL/quicTLS/LibreSSL build. Everything else in this guide — the handshake savings, multiplexing without head-of-line blocking, connection migration — works fine on the OpenSSL compat layer. 0-RTT is a bonus, and one with replay caveats, not the point of HTTP/3.

How it works

HTTP/3 cannot be discovered. A browser resolving your hostname has no way to guess that a UDP service is waiting on port 443, and it will not speculatively probe for one. So the first connection is always ordinary HTTP/1.1 or HTTP/2 over TCP. What changes everything is a single response header on that first request: Alt-Svc, which tells the client “the same origin is also reachable as h3 on this port, and you can remember that for ma seconds.”

Sequence diagram showing a browser making a first request over TCP, receiving an Alt-Svc header advertising h3, then sending subsequent requests over QUIC on UDP 443

That is why the config has two listeners on the same port number. listen 443 ssl; handles TCP and is what carries the advertisement. listen 443 quic reuseport; opens the UDP socket that actually serves HTTP/3 once the browser acts on the advertisement. Drop either one and the feature silently does nothing: without the TCP listener nobody ever learns about h3, and without the UDP listener the browser tries once, fails, and quietly falls back to TCP forever.

nginx does not send Alt-Svc on its own. There is no directive that turns it on — you add it with add_header, and the port you name inside it must match the port you are actually listening on. This is the single most common reason a correct-looking QUIC config never serves a single HTTP/3 request.

Step-by-step

1. Check what your binary can do. Everything downstream depends on this answer:

nginx -v
nginx -V 2>&1 | tr ' ' '\n' | grep -E 'http_v3|http_ssl|with-openssl'

You want a version of at least 1.25.0 and a line reading --with-http_v3_module. If that flag is absent, no amount of config will help — nginx will reject quic on the listen line with invalid parameter "quic" and refuse to start.

2. Install a build that has the module, if yours doesn’t. On Debian or Ubuntu, switch to the official nginx.org mainline repository rather than the distro archive:

curl -fsSL https://nginx.org/keys/nginx_signing.key \
  | sudo gpg --dearmor -o /usr/share/keyrings/nginx-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg] \
http://nginx.org/packages/mainline/ubuntu $(lsb_release -cs) nginx" \
  | sudo tee /etc/apt/sources.list.d/nginx-mainline.list
sudo apt update && sudo apt install nginx

Re-run nginx -V afterwards; the mainline package prints --with-http_v3_module in its configure arguments. Note this replaces your packaged nginx, so back up /etc/nginx first. Compiling from source with ./configure --with-http_v3_module --with-http_ssl_module is the other route if you have local build requirements.

3. Add the QUIC listener alongside the existing TLS one. Edit your server block so both listeners sit on the same port:

server {
    listen 443 quic reuseport;
    listen [::]:443 quic reuseport;
    listen 443 ssl;
    listen [::]:443 ssl;

    http2 on;
    server_name example.com;

    ssl_certificate     /etc/letsencrypt/live/example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/example.com/privkey.pem;
    ssl_protocols       TLSv1.2 TLSv1.3;

    location / {
        add_header Alt-Svc 'h3=":443"; ma=86400' always;
        root /var/www/example.com;
    }
}

Using the same port number for QUIC and HTTPS is what the nginx documentation recommends, and it keeps Alt-Svc simple. reuseport gives each worker process its own UDP socket so QUIC packets are distributed properly — but see step 5 for the constraint it carries.

4. Make sure TLS 1.3 is actually enabled. QUIC requires it; there is no negotiating down. If your ssl_protocols line still reads TLSv1.2 alone, HTTP/3 handshakes will fail even with a perfect listener:

grep -rn 'ssl_protocols' /etc/nginx/

Every match should include TLSv1.3. If you are tightening this at the same time, TLS cipher hardening on nginx covers the cipher side.

5. Declare reuseport exactly once per address and port. nginx accepts reuseport only once for a given address:port pair. If you host several sites, put it on one server block only:

grep -rn 'quic' /etc/nginx/sites-enabled/ /etc/nginx/conf.d/ 2>/dev/null

Every virtual host still needs its own listen 443 quic; line, but only the first one carries reuseport. All other server blocks omit it.

6. Test the config and reload.

sudo nginx -t && sudo systemctl reload nginx

Success is syntax is ok followed by test is successful. If you see invalid parameter "quic", return to step 1 — the module is missing.

7. Open UDP/443 everywhere it is filtered. This is the step that quietly defeats most first attempts, because nothing in nginx’s logs will tell you it happened:

sudo ufw allow 443/udp
sudo ufw status | grep 443

On firewalld:

sudo firewall-cmd --permanent --add-port=443/udp
sudo firewall-cmd --reload
sudo firewall-cmd --list-ports

Then do the same in your cloud security group or hardware firewall — an AWS security group, OVH firewall, or Hetzner rule that allows “HTTPS” almost always means TCP 443 only, and inbound UDP 443 has to be added as a separate rule.

8. Confirm nginx is really bound to the UDP socket.

sudo ss -ulnp | grep :443

You should see one UNCONN 0 0 0.0.0.0:443 line per nginx worker process (that repetition is reuseport working as intended). No output means the QUIC listener never came up.

Validate it works

Start with the cheap check — the advertisement itself, over plain TCP:

curl -sI https://example.com/ | grep -i alt-svc

Expected output: alt-svc: h3=":443"; ma=86400. If this line is missing, browsers will never attempt HTTP/3 no matter how correct the rest of your setup is.

Now the real connection. Be aware that the curl shipped by most distributions cannot do this — Debian, Ubuntu, and RHEL builds are compiled against a TLS library without QUIC support, and curl --http3 returns the installed libcurl version does not support this. Check first:

curl -V | grep -o HTTP3

If that prints nothing, use a container with an HTTP/3-capable build instead of fighting your system package:

docker run --rm ghcr.io/curl/curl-container/curl-multi:master \
  -sI --http3-only https://example.com/

A successful response begins with HTTP/3 200. The --http3 flag alone allows a TCP fallback, which makes a passing result meaningless; --http3-only fails loudly instead of hiding the problem.

Two alternatives if containers are inconvenient. nghttp3’s example client from the ngtcp2 project connects directly and prints the negotiated protocol. And in Chrome or Edge, open DevTools, go to the Network tab, right-click the column headers, enable Protocol, then reload twice — the first load is TCP by design, the second should show h3. Firefox shows the same information under the Network tab’s Protocol column.

Finally, confirm it server-side by logging the negotiated protocol. Add the $http3 variable to a log format:

log_format quiclog '$remote_addr "$request" $status $http3';

Requests served over QUIC log h3; TCP requests log an empty value. This is the most trustworthy signal of all, because it reflects what real visitors are doing rather than what your test client can do.

Troubleshooting

nginx: [emerg] invalid parameter "quic" — the binary has no v3 module. Confirm with nginx -V 2>&1 | grep http_v3. Nothing in the config can work around a missing module; install the nginx.org mainline package or rebuild with --with-http_v3_module. This is by far the most common failure, because upgrading nginx to 1.25+ from a distro archive does not necessarily add the module.

Config loads, ss shows the UDP socket, but no client ever gets h3 — UDP/443 is blocked somewhere. Test from an external host with nc -zvu example.com 443, or watch for arriving packets with sudo tcpdump -ni any udp port 443 while you reload a browser tab. Silence means the packets are dying upstream: check the host firewall and every network layer above it separately, since fixing one and not the other looks identical from the server.

Browsers stay on HTTP/2 forever, and curl --http3-only works fine — you are missing Alt-Svc, or it is being dropped. Check with curl -sI. Two subtleties bite here: add_header in nginx is not inherited into a location block that declares its own add_header, so a header set at server level can vanish on specific paths; and headers are not emitted on non-2xx responses unless you append always. Also verify the port inside the header matches your actual listener — advertising h3=":8443" while listening on 443 sends every client to a closed door.

nginx: [emerg] duplicate listen options for 0.0.0.0:443 — reuseport appears in more than one server block for the same address and port. Find them with grep -rn reuseport /etc/nginx/, keep it on exactly one, and delete it from the rest. Each site keeps its plain listen 443 quic; line.

Handshakes fail intermittently, often on mobile networks — QUIC Initial packets are larger than some paths allow, or an intermediate device is mangling UDP. Enable address validation with quic_retry on;, which also raises the cost of address-spoofing floods. On Linux hosts with UDP_SEGMENT support, quic_gso on; reduces syscall overhead on high-traffic servers. Set quic_host_key to a persistent file if you use quic_retry, otherwise the key is regenerated on every reload and in-flight tokens are invalidated. Ignore http3_hq entirely — it exists for QUIC interoperability testing, not production.

When this is the wrong approach

If a CDN or edge proxy already terminates TLS in front of you — Cloudflare, Fastly, CloudFront — it is almost certainly serving HTTP/3 to visitors already, and the hop between the edge and your origin is a long-lived, well-tuned connection where QUIC changes nothing measurable. Enabling it on the origin adds an attack surface and a UDP firewall rule for no gain. Check what the edge already advertises before touching the origin config.

The same goes for traffic that never crosses a lossy network. QUIC’s advantages — a faster handshake, no TCP head-of-line blocking when a packet is lost — scale with round-trip time and packet loss. On a LAN, between containers, or between services in the same availability zone, RTT is well under a millisecond and loss is effectively zero, so there is nothing for QUIC to recover. Internal APIs and service-to-service calls are better left on HTTP/2, which is simpler to operate and has no UDP dependency.

Be realistic about the payoff generally. HTTP/3 helps most for mobile users, high-latency links, and lossy Wi-Fi. For a desktop audience on fibre, the difference is often within measurement noise — worth having, not worth an emergency change window. And note the module is still marked experimental in the nginx documentation, which is a reasonable argument for rolling it out to one host first and watching your error rates.

The official ngx_http_v3_module documentation is the authoritative reference for every directive here, including the tuning knobs this guide skipped.

If this is the kind of work you’d rather never own again, it’s the daily job of Managed Cloud Ops — book an infrastructure review.