Skip to content

URL rendered and opened on wrong port when 8888 already in use #1126

@alexscordellis

Description

@alexscordellis

Description

URL printed in console output (and automatically opened in browser) has the wrong port, if port 8888 was already in use.

Reproduce

  1. Ensure port 8888 is already in use on your system (e.g. by running another jupyter server)
  2. Launch a new jupyter classic server or lab jupyter nbclassic or jupyter lab.
  3. Server will run on port 8889 because 8888 is in use
  4. Error: URL printed in console and auto-opened in your browser will be port 8888, but the server will run on 8889

This happens with jupyter lab and jupyter nbclassic, but not jupyter notebook, which correctly prints + opens port 8889.

> jupyter  nbclassic
[I 2022-12-09 11:21:15.316 ServerApp] jupyter_server_terminals | extension was successfully linked.
[I 2022-12-09 11:21:15.323 ServerApp] jupyterlab | extension was successfully linked.
[I 2022-12-09 11:21:15.328 ServerApp] nbclassic | extension was successfully linked.
[I 2022-12-09 11:21:16.891 ServerApp] pyql | extension was found and enabled by notebook_shim. Consider moving the extension to Jupyter Server's extension paths.
[I 2022-12-09 11:21:16.892 ServerApp] pyql | extension was successfully linked.
[I 2022-12-09 11:21:16.892 ServerApp] notebook_shim | extension was successfully linked.
[I 2022-12-09 11:21:16.932 ServerApp] notebook_shim | extension was successfully loaded.
[I 2022-12-09 11:21:16.933 ServerApp] jupyter_server_terminals | extension was successfully loaded.
[I 2022-12-09 11:21:16.934 LabApp] JupyterLab extension loaded from e:\venv\REDACTED\lib\site-packages\jupyterlab
[I 2022-12-09 11:21:16.934 LabApp] JupyterLab application directory is E:\venv\REDACTED\share\jupyter\lab
[I 2022-12-09 11:21:16.937 ServerApp] jupyterlab | extension was successfully loaded.
[I 2022-12-09 11:21:16.945 ServerApp] nbclassic | extension was successfully loaded.
[I 2022-12-09 11:21:16.945 ServerApp] REDACTEDmodule enabled!
[I 2022-12-09 11:21:16.945 ServerApp] REDACTED | extension was successfully loaded.
[I 2022-12-09 11:21:16.946 ServerApp] Serving notebooks from local directory: E:\notebooks
[I 2022-12-09 11:21:16.946 ServerApp] Jupyter Server 2.0.1 is running at:
[I 2022-12-09 11:21:16.946 ServerApp] http://localhost:8888/tree?token=566732ef708ff77eea9b3c6c6f43c26b7eb2b409e3a48d02
[I 2022-12-09 11:21:16.946 ServerApp]  or http://127.0.0.1:8888/tree?token=566732ef708ff77eea9b3c6c6f43c26b7eb2b409e3a48d02
[I 2022-12-09 11:21:16.946 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 2022-12-09 11:21:17.128 ServerApp]

    To access the server, open this file in a browser:
        file:///C:/Users/alexs/AppData/Roaming/jupyter/runtime/jpserver-41204-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/tree?token=566732ef708ff77eea9b3c6c6f43c26b7eb2b409e3a48d02
     or http://127.0.0.1:8888/tree?token=566732ef708ff77eea9b3c6c6f43c26b7eb2b409e3a48d02
[I 2022-12-09 11:21:17.129 ServerApp] The port 8888 is already in use, trying another port.
> jupyter lab
[I 2022-12-09 10:22:37.551 ServerApp] jupyter_server_terminals | extension was successfully linked.
[I 2022-12-09 10:22:37.558 ServerApp] jupyterlab | extension was successfully linked.
[I 2022-12-09 10:22:37.563 ServerApp] nbclassic | extension was successfully linked.
[I 2022-12-09 10:22:39.154 ServerApp] pyql | extension was found and enabled by notebook_shim. Consider moving the extension to Jupyter Server's extension paths.
[I 2022-12-09 10:22:39.154 ServerApp] pyql | extension was successfully linked.
[I 2022-12-09 10:22:39.155 ServerApp] notebook_shim | extension was successfully linked.
[I 2022-12-09 10:22:39.197 ServerApp] notebook_shim | extension was successfully loaded.
[I 2022-12-09 10:22:39.198 ServerApp] jupyter_server_terminals | extension was successfully loaded.
[I 2022-12-09 10:22:39.199 LabApp] JupyterLab extension loaded from e:\venv\REDACTED\lib\site-packages\jupyterlab
[I 2022-12-09 10:22:39.199 LabApp] JupyterLab application directory is E:\venv\REDACTED\share\jupyter\lab
[I 2022-12-09 10:22:39.203 ServerApp] jupyterlab | extension was successfully loaded.
[I 2022-12-09 10:22:39.211 ServerApp] nbclassic | extension was successfully loaded.
[I 2022-12-09 10:22:39.212 ServerApp] REDACTEDmodule enabled!
[I 2022-12-09 10:22:39.212 ServerApp] REDACTED | extension was successfully loaded.
[I 2022-12-09 10:22:39.212 ServerApp] Serving notebooks from local directory: E:\notebooks
[I 2022-12-09 10:22:39.212 ServerApp] Jupyter Server 2.0.1 is running at:
[I 2022-12-09 10:22:39.212 ServerApp] http://localhost:8888/lab?token=f91375cac575b41eca29a47fa7d6104e83fbc27d5cb4922c
[I 2022-12-09 10:22:39.212 ServerApp]  or http://127.0.0.1:8888/lab?token=f91375cac575b41eca29a47fa7d6104e83fbc27d5cb4922c
[I 2022-12-09 10:22:39.212 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 2022-12-09 10:22:39.403 ServerApp]

    To access the server, open this file in a browser:
        file:///C:/Users/alexs/AppData/Roaming/jupyter/runtime/jpserver-20888-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/lab?token=f91375cac575b41eca29a47fa7d6104e83fbc27d5cb4922c
     or http://127.0.0.1:8888/lab?token=f91375cac575b41eca29a47fa7d6104e83fbc27d5cb4922c
[I 2022-12-09 10:22:39.404 ServerApp] The port 8888 is already in use, trying another port.

Expected behavior

jupyter notebook displays the correct behaviour: the port printed to the console and opened on the browser are 8889.

 jupyter  notebook ./SomeNotebook.ipynb
[W 2022-12-09 10:29:47.481 LabApp] 'file_to_run' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[W 2022-12-09 10:29:47.481 LabApp] 'file_to_run' has moved from NotebookApp to ServerApp. This config will be passed to ServerApp. Be sure to update your config before our next release.
[I 2022-12-09 10:29:47.487 LabApp] JupyterLab extension loaded from e:\venv\REDACTED\lib\site-packages\jupyterlab
[I 2022-12-09 10:29:47.487 LabApp] JupyterLab application directory is E:\venv\REDACTED\share\jupyter\lab
[I 10:29:48.670 NotebookApp] REDACTEDmodule enabled!
[I 10:29:48.671 NotebookApp] The port 8888 is already in use, trying another port.
[I 10:29:48.672 NotebookApp] Serving notebooks from local directory: E:\notebooks
[I 10:29:48.673 NotebookApp] Jupyter Notebook 6.5.2 is running at:
[I 10:29:48.673 NotebookApp] http://localhost:8889/?token=ae85393e1bca602b5dbf5d3da66e63c8d6f834242c4ead90
[I 10:29:48.673 NotebookApp]  or http://127.0.0.1:8889/?token=ae85393e1bca602b5dbf5d3da66e63c8d6f834242c4ead90
[I 10:29:48.673 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 10:29:48.850 NotebookApp]

    To access the notebook, open this file in a browser:
        file:///C:/Users/alexs/AppData/Roaming/jupyter/runtime/nbserver-56748-open.html
    Or copy and paste one of these URLs:
        http://localhost:8889/?token=ae85393e1bca602b5dbf5d3da66e63c8d6f834242c4ead90
     or http://127.0.0.1:8889/?token=ae85393e1bca602b5dbf5d3da66e63c8d6f834242c4ead90

Context

  • Windows 10 Enterprise
  • Browser version: n/a
  • Jupyter Server version: 2.16.5
Troubleshoot Output
> jupyter troubleshoot                                                                                        [11:27:17 on 22-12-09]
$PATH:  
        E:\venv\REDACTED\Scripts
        REDACTED

sys.path:
E:\venv\REDACTED\Scripts\jupyter-troubleshoot.EXE
REDACTED

sys.executable:
e:\venv\REDACTED\scripts\python.exe

sys.version:
3.8.7 (tags/v3.8.7:6503f05, Dec 21 2020, 17:59:51) [MSC v.1928 64 bit (AMD64)]

platform.platform():
Windows-10-10.0.19041-SP0

where jupyter:
E:\venv\REDACTED\Scripts\jupyter.exe

pip list:
Company internal packages redacted

    Package                     Version
    --------------------------- -----------
    aiofiles                    22.1.0
    aiohttp                     3.8.3
    aiosignal                   1.3.1
    anyio                       3.6.2
    argon2-cffi                 21.3.0
    argon2-cffi-bindings        21.2.0
    asttokens                   2.2.1
    async-timeout               4.0.2
    attrs                       22.1.0
    Babel                       2.11.0
    backcall                    0.2.0
    backports.zoneinfo          0.2.1
    bcrypt                      4.0.1
    beautifulsoup4              4.11.1
    bitmath                     1.3.3.1
    bleach                      5.0.1
    bson                        0.5.10
    cachetools                  5.2.0
    certifi                     2022.12.7
    cffi                        1.15.1
    charset-normalizer          2.1.1
    click                       8.1.3
    cloudpickle                 2.2.0
    colorama                    0.4.6
    comm                        0.1.2
    contourpy                   1.0.6
    cryptography                38.0.4
    cycler                      0.11.0
    Cython                      0.29.32
    dataclasses-json            0.5.7
    debugpy                     1.6.4
    decorator                   5.1.1
    defusedxml                  0.7.1
    entrypoints                 0.4
    executing                   1.2.0
    fastjsonschema              2.16.2
    fonttools                   4.38.0
    frozenlist                  1.3.3
    google-auth                 2.15.0
    greenlet                    2.0.1
    gssapi                      1.8.2
    idna                        3.4
    importlib-metadata          5.1.0
    importlib-resources         5.10.1
    ipykernel                   6.19.2
    ipython                     8.7.0
    ipython-genutils            0.2.0
    ipywidgets                  8.0.3
    isort                       5.10.1
    jedi                        0.18.2
    Jinja2                      3.1.2
    json5                       0.9.10
    jsonschema                  4.17.3
    jupyter-client              7.4.8
    jupyter-core                5.1.0
    jupyter-events              0.5.0
    jupyter-server              2.0.1
    jupyter-server-terminals    0.4.2
    jupyterlab                  3.5.1
    jupyterlab-pygments         0.2.2
    jupyterlab-server           2.16.5
    jupyterlab-widgets          3.0.4
    kiwisolver                  1.4.4
    kubernetes                  25.3.0
    llvmlite                    0.39.1
    MarkupSafe                  2.1.1
    marshmallow                 3.19.0
    marshmallow-dataclass       8.5.10
    marshmallow-enum            1.5.1
    matplotlib                  3.6.2
    matplotlib-inline           0.1.6
    memory-profiler             0.61.0
    mistune                     2.0.4
    more-itertools              9.0.0
    multidict                   6.0.3
    mypy-extensions             0.4.3
    nbclassic                   0.4.8
    nbclient                    0.7.2
    nbconvert                   7.2.6
    nbformat                    5.7.0
    nest-asyncio                1.5.6
    notebook                    6.5.2
    notebook-shim               0.2.2
    numba                       0.56.4
    numpy                       1.23.5
    oauthlib                    3.2.2
    packaging                   22.0
    pandas                      1.5.2
    pandocfilters               1.5.0
    parso                       0.8.3
    pathlib                     1.0.1
    patsy                       0.5.3
    pickleshare                 0.7.5
    Pillow                      9.3.0
    pip                         20.2.3
    pipdeptree                  2.3.3
    pkce                        1.0.3
    pkgutil-resolve-name        1.3.10
    platformdirs                2.6.0
    plotly                      5.11.0
    polars                      0.15.2
    portalocker                 2.6.0
    prometheus-client           0.15.0
    prompt-toolkit              3.0.36
    psutil                      5.9.4
    pure-eval                   0.2.2
    pyarrow                     10.0.1
    pyasn1                      0.4.8
    pyasn1-modules              0.2.8
    pycparser                   2.21
    pydantic                    1.9.2
    Pygments                    2.13.0
    pylogbeat                   2.0.0
    pyodbc                      4.0.35
    pyOpenSSL                   22.1.0
    pyparsing                   3.0.9
    pypiwin32                   223
    pyrsistent                  0.19.2
    python-dateutil             2.8.2
    python-json-logger          2.0.4
    pytz                        2022.6
    pywin32                     305
    pywinpty                    2.0.9
    PyYAML                      5.4.1
    pyzmq                       24.0.1
    quadprog                    0.1.11
    regex                       2022.10.31
    requests                    2.28.1
    requests-kerberos           0.12.0
    requests-negotiate-sspi     0.5.2
    requests-oauthlib           1.3.1
    retrying                    1.3.4
    rsa                         4.9
    scipy                       1.9.3
    seaborn                     0.12.1
    semantic-version            2.10.0
    Send2Trash                  1.8.0
    setuptools                  49.2.1
    shiv                        1.0.3
    six                         1.16.0
    sklearn                     0.0.post1
    sniffio                     1.3.0
    soupsieve                   2.3.2.post1
    SQLAlchemy                  1.4.44
    stack-data                  0.6.2
    statsmodels                 0.13.5
    tenacity                    8.1.0
    terminado                   0.17.1
    tinycss2                    1.2.1
    tomli                       2.0.1
    tornado                     6.2
    tqdm                        4.64.1
    traitlets                   5.7.0
    typeguard                   2.13.3
    typing-extensions           4.4.0
    typing-inspect              0.8.0
    tzdata                      2022.7
    urllib3                     1.26.13
    wcwidth                     0.2.5
    webencodings                0.5.1
    websocket-client            1.4.2
    wheel                       0.38.4
    widgetsnbextension          4.0.4
    winkerberos                 0.9.1
    xarray                      2022.12.0
    yarl                        1.8.2
    yattag                      1.14.0
    zipp                        3.11.0
Command Line Output
[D 2022-12-09 11:31:15.402 ServerApp] Searching ['e:\\venv\\REDACTED\\etc\\jupyter', 'C:\\Users\\alexs\\.jupyter', 'C:\\ProgramData\\jupyter'] for config files
[D 2022-12-09 11:31:15.403 ServerApp] Looking for jupyter_config in C:\ProgramData\jupyter
[D 2022-12-09 11:31:15.403 ServerApp] Looking for jupyter_config in C:\Users\alexs\.jupyter
[D 2022-12-09 11:31:15.404 ServerApp] Looking for jupyter_config in e:\venv\REDACTED\etc\jupyter
[D 2022-12-09 11:31:15.405 ServerApp] Looking for jupyter_server_config in C:\ProgramData\jupyter
[D 2022-12-09 11:31:15.405 ServerApp] Looking for jupyter_server_config in C:\Users\alexs\.jupyter
[D 2022-12-09 11:31:15.405 ServerApp] Looking for jupyter_server_config in e:\venv\REDACTED\etc\jupyter
[D 2022-12-09 11:31:15.408 ServerApp] Paths used for configuration of jupyter_server_config:
        C:\ProgramData\jupyter\jupyter_server_config.json
[D 2022-12-09 11:31:15.409 ServerApp] Paths used for configuration of jupyter_server_config:
        C:\Users\alexs\.jupyter\jupyter_server_config.json
[D 2022-12-09 11:31:15.409 ServerApp] Paths used for configuration of jupyter_server_config:
        e:\venv\REDACTED\etc\jupyter\jupyter_server_config.d\jupyter_server_terminals.json
        e:\venv\REDACTED\etc\jupyter\jupyter_server_config.d\jupyterlab.json
        e:\venv\REDACTED\etc\jupyter\jupyter_server_config.d\nbclassic.json
        e:\venv\REDACTED\etc\jupyter\jupyter_server_config.d\notebook_shim.json
        e:\venv\REDACTED\etc\jupyter\jupyter_server_config.json
[D 2022-12-09 11:31:15.436 TerminalsExtensionApp] Config changed: {'ServerApp': {'log_level': 'DEBUG', 'jpserver_extensions': }, 'ExtensionApp': {'log_level': 'DEBUG'}}
[D 2022-12-09 11:31:15.437 ServerApp] Config changed: {'ServerApp': {'log_level': 'DEBUG', 'jpserver_extensions': }, 'ExtensionApp': {'log_level': 'DEBUG'}}
[I 2022-12-09 11:31:15.438 ServerApp] jupyter_server_terminals | extension was successfully linked.
[D 2022-12-09 11:31:15.445 LabApp] Config changed: {'NotebookApp': {}, 'ServerApp': {'log_level': 'DEBUG', 'jpserver_extensions': }, 'ExtensionApp': {'log_level': 'DEBUG'}}
[I 2022-12-09 11:31:15.446 ServerApp] jupyterlab | extension was successfully linked.
[D 2022-12-09 11:31:15.451 NotebookApp] Config changed: {'NotebookApp': {}, 'ServerApp': {'log_level': 'DEBUG', 'jpserver_extensions': }, 'ExtensionApp': {'log_level': 'DEBUG'}}
[I 2022-12-09 11:31:15.452 ServerApp] nbclassic | extension was successfully linked.
[D 2022-12-09 11:31:15.839 ServerApp] Paths used for configuration of jupyter_notebook_config:
        C:\Users\alexs\.jupyter\jupyter_notebook_config.json
[D 2022-12-09 11:31:15.840 ServerApp] Paths used for configuration of jupyter_notebook_config:
        C:\ProgramData\jupyter\jupyter_notebook_config.json
[D 2022-12-09 11:31:15.840 ServerApp] Paths used for configuration of jupyter_notebook_config:
        C:\Users\alexs\.jupyter\jupyter_notebook_config.json
[D 2022-12-09 11:31:15.841 ServerApp] Paths used for configuration of jupyter_notebook_config:
        e:\venv\REDACTED\etc\jupyter\jupyter_notebook_config.d\jupyterlab.json
        e:\venv\REDACTED\etc\jupyter\jupyter_notebook_config.d\REDACTED.json
        e:\venv\REDACTED\etc\jupyter\jupyter_notebook_config.json
[I 2022-12-09 11:31:16.969 ServerApp] REDACTED | extension was found and enabled by notebook_shim. Consider moving the extension to Jupyter Server's extension paths.
[I 2022-12-09 11:31:16.970 ServerApp] REDACTED | extension was successfully linked.
[I 2022-12-09 11:31:16.970 ServerApp] notebook_shim | extension was successfully linked.
[D 2022-12-09 11:31:16.971 ServerApp] Config changed: {'ExtensionApp': {'log_level': 'DEBUG'}, 'NotebookApp': {}, 'ServerApp': {'log_level': 'DEBUG', 'jpserver_extensions': }}
[D 2022-12-09 11:31:16.971 ServerApp] Ignoring min_open_files_limit because the limit cannot be adjusted (for example, on Windows)
[I 2022-12-09 11:31:17.010 ServerApp] notebook_shim | extension was successfully loaded.
[I 2022-12-09 11:31:17.011 ServerApp] jupyter_server_terminals | extension was successfully loaded.
[I 2022-12-09 11:31:17.012 LabApp] JupyterLab extension loaded from e:\venv\REDACTED\lib\site-packages\jupyterlab
[I 2022-12-09 11:31:17.012 LabApp] JupyterLab application directory is E:\venv\REDACTED\share\jupyter\lab
[I 2022-12-09 11:31:17.015 ServerApp] jupyterlab | extension was successfully loaded.
[I 2022-12-09 11:31:17.022 ServerApp] nbclassic | extension was successfully loaded.
[I 2022-12-09 11:31:17.022 ServerApp] REDACTED module enabled!
[I 2022-12-09 11:31:17.023 ServerApp] REDACTED | extension was successfully loaded.
[I 2022-12-09 11:31:17.023 ServerApp] Serving notebooks from local directory: E:\notebooks
[I 2022-12-09 11:31:17.023 ServerApp] Jupyter Server 2.0.1 is running at:
[I 2022-12-09 11:31:17.023 ServerApp] http://localhost:8888/lab?token=56dcda147626eb75a6f5c70d3331db2d4c6801e53d924c19
[I 2022-12-09 11:31:17.023 ServerApp]  or http://127.0.0.1:8888/lab?token=56dcda147626eb75a6f5c70d3331db2d4c6801e53d924c19
[I 2022-12-09 11:31:17.023 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 2022-12-09 11:31:17.200 ServerApp]
To access the server, open this file in a browser:
    file:///C:/Users/alexs/AppData/Roaming/jupyter/runtime/jpserver-99356-open.html
Or copy and paste one of these URLs:
    http://localhost:8888/lab?token=56dcda147626eb75a6f5c70d3331db2d4c6801e53d924c19
 or http://127.0.0.1:8888/lab?token=56dcda147626eb75a6f5c70d3331db2d4c6801e53d924c19

[I 2022-12-09 11:31:17.202 ServerApp] The port 8888 is already in use, trying another port.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions