Add --bind / -b option for multiple socket bindings#2818
Open
Add --bind / -b option for multiple socket bindings#2818
--bind / -b option for multiple socket bindings#2818Conversation
Allow binding to multiple addresses simultaneously using the established pattern from Gunicorn and Hypercorn. Supports HOST:PORT, [HOST]:PORT (IPv6), unix:PATH, and fd://NUM formats. Mutually exclusive with --host/--port/--uds/--fd.
Add tests for bind_sockets() with unix: and fd:// formats, and for UDS cleanup in run(). Mark uncoverable branches with pragma: py-win32.
Owner
Author
vvanglro
approved these changes
Feb 16, 2026
Contributor
|
LGTM! |
Owner
Author
Thanks for the review! |
…perty Move the `--bind` mutual exclusivity check to the end of `Config.__init__` alongside other cross-field validation. Add a `bind_unix_paths` property to encapsulate unix socket path extraction, and use it in the cleanup code in `main.py`. Add a docs note explaining when to use `--bind`.
Move the bind socket resolution from startup() to _serve() so startup doesn't need to know about config.bind. The resolved sockets flow into both startup and shutdown through the existing parameter.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add a
--bind/-boption for binding to multiple addresses simultaneously. AcceptsHOST:PORT,[HOST]:PORT(IPv6),unix:PATH, andfd://NUMformats. Mutually exclusive with--host/--port/--uds/--fd, fully backwards compatible.Supersedes #2486, which changed
--hostto accept multiple values - that approach altered the type signature ofhostfromstrtolist[str], breaking the existing API. A dedicated--bindoption avoids that, and also covers mixed binding types (e.g. TCP + UDS) that multi-host alone can't express. This follows the pattern established by Gunicorn and Hypercorn.Closes #2808 as well, which hardcoded UDS + host/port together rather than offering a general mechanism.