Skip to content

Comments

Add --bind / -b option for multiple socket bindings#2818

Open
Kludex wants to merge 6 commits intomainfrom
add-bind-option
Open

Add --bind / -b option for multiple socket bindings#2818
Kludex wants to merge 6 commits intomainfrom
add-bind-option

Conversation

@Kludex
Copy link
Owner

@Kludex Kludex commented Feb 15, 2026

Add a --bind / -b option for binding to multiple addresses simultaneously. Accepts HOST:PORT, [HOST]:PORT (IPv6), unix:PATH, and fd://NUM formats. Mutually exclusive with --host/--port/--uds/--fd, fully backwards compatible.

Supersedes #2486, which changed --host to accept multiple values - that approach altered the type signature of host from str to list[str], breaking the existing API. A dedicated --bind option 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.

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.
@Kludex
Copy link
Owner Author

Kludex commented Feb 15, 2026

@vvanglro since you've worked on #2486, what do you think about this PR?

@vvanglro
Copy link
Contributor

LGTM!

@Kludex
Copy link
Owner Author

Kludex commented Feb 16, 2026

LGTM!

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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants