New Features
- Glob patterns in
reload_extra_files: entries containing*,?or[
are treated as patterns, soui/*/config.jsonwatches every view's config
without listing them one by one. Patterns are re-expanded on every reload
check rather than once at startup, so a file created later starts being
watched without restarting gunicorn, and**recurses. A pattern matching
nothing warns instead of failing, since with live expansion it may match later
(#1643,
#3662).
Security
- Dependency floors raised past known advisories: every declared floor was
checked against the advisory database.tornado,h2,setuptoolsand
pymdown-extensionspermitted vulnerable versions and now require the first
clean release;pytestandhttpxwere unpinned and now carry floors. The
tornadoexample pinnedtornado<6, which was both the source of several
advisories and older than the>=6.5.0the tornado worker needs, so the
example could not run as pinned.
Bug Fixes
-
SIGHUP did not reload the logger configuration:
Arbiter.reload()
re-read the configuration file but kept using the logger built at startup,
calling onlyreopen_files()on its existing handlers. Changes to
logconfig,logconfig_dict,logconfig_jsonandloglevelwere ignored
until a full restart, which in containers meant replacing the pod. The
existing logger now re-runs its setup on reload, so new handlers, formats
and levels take effect while the process identity and its listeners are
preserved, and re-running the setup no longer stacks duplicate syslog
handlers. An invalid log configuration on reload is not fatal either: the
error is reported on stderr, the previous working configuration is restored
and the master keeps running with it
(#3353). -
Truncated chunked bodies accepted: RFC 9112 section 7.1.2 ends a chunked
body with0 CRLF CRLF, the second CRLF being the mandatory empty trailer
section.ChunkedReader.parse_chunk_size()swallowed theNoMoreDataraised
while scanning for it, so a body cut short right after the last chunk line was
treated as complete instead of rejected. It now raises
ChunkMissingTerminator
(#3382,
#3685). -
--spewcrashed on dynamically generated code: the trace hook indexed the
2-tuple returned byinspect.getsourcelines()by line number rather than
indexing the list of lines, so a frame with no__file__raised
AttributeError: 'int' object has no attribute 'rstrip'on line 1 and
IndexErrorbeyond it. The tuple is now unpacked and offset by the source's
starting line (#3344,
#3495). -
Duplicate
HostandContent-Typeheaders accepted: RFC 9110 section 5.3
allows only one of each, and a repeat cannot be merged into a list, so the
message means different things to gunicorn and to anything downstream. Both
are now rejected withInvalidHeader. The check lives in the policy hook
shared by both parsers, so the pure-Python and fast parsers agree. Duplicate
Content-Lengthwas already rejected and is unchanged
(#3366,
#3548). -
Non-worker children reported as failed workers:
reap_workers()reaps
every child throughwaitpid(-1), including processes the kernel reparented
onto gunicorn when it runs as PID 1 in a container, but it logged the exit
status before checking whether the pid was ever a worker. An unrelated process
producedWorker (pid:N) exited with code Mand triggered alerts. More
seriously, such a process exiting with code 3 or 4 raisedHaltServerand shut
the server down. Ownership is now established first: the dirty arbiter is
reported as itself, unknown children are reaped silently at debug level, and
only real workers can halt the server
(#3220,
#3566). -
Dirty arbiter exits were invisible on SIGCHLD:
handle_chld()called
reap_workers()first, whosewaitpid(-1)claimed the dirty arbiter before
reap_dirty_arbiter()could identify it, so the latter always hitECHILDand
its reporting never ran. The dirty arbiter is now reaped first, and
reap_workers()recognises it if it exits mid-loop. -
Dirty arbiter returned stale responses after a worker timeout: when a
request reacheddirty_timeoutthe arbiter answered the client with a timeout
error but kept the worker connection open. The worker's late response was then
the first message waiting on that socket, so the next request routed to the
same worker received the previous request's result, and every request after it
stayed one response behind. The connection is now closed on timeout, so the
late answer is discarded with it
(#3626). -
ASGI connection count leaked on server-initiated close:
nr_connswas
only decremented inconnection_lost(), behind a guard keyed on the same
flag_close_transport()sets first. Every close the server started (a
Connection: closeresponse, a keepalive timeout, an error abort) leaked one
count, soASGIWorker._shutdown()ran the fullgraceful_timeoutand warned
about connections that were already gone. The guard now uses its own flag, so
the decrement and the rest of the cleanup run exactly once whichever side
closes first (#3661). -
Inotify reloader on cwd-relative extra files:
reload_extra_filesentries
with no directory part (for example.env) produced an empty dirname, and
watching it raisedInotifyErrorwithENOENT. The current directory is now
watched as.(#3377,
#3667). -
StatsD zero-valued metrics: gauges, counters, histograms and timers
reporting0were silently dropped because the value was tested for
truthiness. OnlyNoneis skipped now
(#3676). -
Spurious no-body warning from
sendfile(): a HEAD, 204 or 304 response
served throughsendfile()warned about dropped body bytes even when the
file was empty and nothing was dropped. It now warns only when there are
bytes to drop, matchingwrite()
(#3684). -
Bare
exceptin the gevent websocket example: narrowed to
except Exception(#3683). -
ASGI
receive()cancellation: Letasyncio.CancelledErrorpropagate
fromBodyReceiverinstead of swallowing it and returning
http.disconnect. Frameworks that cancel their disconnect listener after
the response completes (Django) no longer see the cancel masked, so
request_finishedfires andclose_old_connections()runs. Fixes idle
database connections leaking since 25.1.0
(#3627,
#3654). -
Control socket leak on SIGHUP reload: The control thread is now marked
ready once its loop and server are live, and the stop paths wait on that
readiness before scheduling shutdown. Reloads no longer leak one thread and
its selector fd plus unix socket per worker, which eventually raised
"too many open files"
(#3648). -
WSGI body framing on HEAD/1xx/204/304: Mirror the ASGI strip-and-warn
behavior on the WSGI path.Content-Lengthis stripped on 1xx/204 per
RFC 9110 section 6.4.2, body bytes are dropped for no-body responses in
bothwrite()andsendfile(), and a single warning is logged per request
(#3413).
Refactoring
- Pass log arguments to the logger instead of pre-formatting the worker
termination message inArbiter.reap_workers()
(#3678).
Changes
-
packagingis no longer a runtime dependency: it was only ever imported by
the gevent worker, to compare gevent's version. It moved to thegeventand
testingextras, so a plainpip install gunicornpulls in nothing
(#3643). -
Fast HTTP Parser: Require
gunicorn_h1c >= 0.6.6, which rejects duplicate
HostandContent-Typeheaders in the C parser itself. Gunicorn already
refuses them on both the WSGI and ASGI paths, so this changes nothing that is
reachable; it moves the rejection to where the bytes are read and lets the
ASGI corpus exercise those cases against the fast parser directly.
Full changelog: https://gunicorn.org/2026-news/