Skip to content

Grab the port from bind_sockets in case its different#1651

Merged
krassowski merged 2 commits into
jupyter-server:mainfrom
choldgraf:bug/port-selection
Jun 2, 2026
Merged

Grab the port from bind_sockets in case its different#1651
krassowski merged 2 commits into
jupyter-server:mainfrom
choldgraf:bug/port-selection

Conversation

@choldgraf
Copy link
Copy Markdown
Contributor

This asks a socket for the port that it has bound to, so that if the port changes (ie, when port=0 and the machine selects a new open port to return), it correctly makes it back into the build logs etc

Locally, I got this before the PR:

$ jupyter server --ServerApp.port=0 --no-browser
...
[I 2026-05-29 15:42:18.443 ServerApp] http://localhost:0/
...

And this after:

$ jupyter server --ServerApp.port=0 --no-browser
...
[I 2026-05-29 15:42:18.443 ServerApp] http://localhost:59976/
...

Comment thread jupyter_server/serverapp.py Outdated
@krassowski krassowski added the bug label Jun 1, 2026
@krassowski krassowski added this to the 2.20 milestone Jun 1, 2026
Copy link
Copy Markdown
Collaborator

@krassowski krassowski left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

@krassowski krassowski changed the title Grab the port from bind_sockets in case its different Grab the port from bind_sockets in case its different Jun 2, 2026
@krassowski krassowski merged commit b8f405a into jupyter-server:main Jun 2, 2026
68 of 69 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Providing ServerApp.port=0 works but the server advertises port 0 instead of the bound port

2 participants