Search code examples
pythonjupytervirtualenvhttp-status-code-404

Jupyter gives 404 errors on Debian and I'm unable to open any notebook


I'm currently unable to use jupyter on my Dell laptop that runs Debian 12. I'm running jupyter lab in a python virtualenv.

When I run jupyter lab I first get the following error message that is recurrent:

[W 2025-01-15 18:44:52.720 ServerApp] 404 GET /api/collaboration/room/JupyterLab:globalAwareness ([email protected]) 39.53ms referer=None

The jupyter menu shows just fine in my firefox browser.

Then when I try to create a new notebook, I get the following 404 error:

[W 2025-01-15 18:45:03.095 ServerApp] 404 PUT /api/collaboration/session/Untitled.ipynb?1736963103090 ([email protected]) 1.33ms referer=http://localhost:8888/lab

And the opened notebook doesn't load: new notebook not loading

Here is some console output:

$ jupyter lab
[I 2025-01-15 18:44:09.733 ServerApp] jupyter_lsp | extension was successfully linked.
[I 2025-01-15 18:44:09.736 ServerApp] jupyter_server_terminals | extension was successfully linked.
[I 2025-01-15 18:44:09.740 ServerApp] jupyterlab | extension was successfully linked.
[I 2025-01-15 18:44:09.899 ServerApp] notebook_shim | extension was successfully linked.
[I 2025-01-15 18:44:09.909 ServerApp] notebook_shim | extension was successfully loaded.
[I 2025-01-15 18:44:09.910 ServerApp] jupyter_lsp | extension was successfully loaded.
[I 2025-01-15 18:44:09.911 ServerApp] jupyter_server_terminals | extension was successfully loaded.
[I 2025-01-15 18:44:09.911 LabApp] JupyterLab extension loaded from /home/noe/Documents/univ/TER/venv/lib/python3.11/site-packages/jupyterlab
[I 2025-01-15 18:44:09.912 LabApp] JupyterLab application directory is /home/noe/Documents/univ/TER/venv/share/jupyter/lab
[I 2025-01-15 18:44:09.912 LabApp] Extension Manager is 'pypi'.
[I 2025-01-15 18:44:09.991 ServerApp] jupyterlab | extension was successfully loaded.
[I 2025-01-15 18:44:09.991 ServerApp] Serving notebooks from local directory: /home/noe/Documents/univ/TER/venv
[I 2025-01-15 18:44:09.991 ServerApp] Jupyter Server 2.15.0 is running at:
[I 2025-01-15 18:44:09.991 ServerApp] http://localhost:8888/lab?token=6b54a68b3230f79b6f719f36cdfd9e3dbafcdcba3bc270e7
[I 2025-01-15 18:44:09.991 ServerApp]     http://127.0.0.1:8888/lab?token=6b54a68b3230f79b6f719f36cdfd9e3dbafcdcba3bc270e7
[I 2025-01-15 18:44:09.991 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 2025-01-15 18:44:10.009 ServerApp] 
    
    To access the server, open this file in a browser:
        file:///home/noe/.local/share/jupyter/runtime/jpserver-27699-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/lab?token=6b54a68b3230f79b6f719f36cdfd9e3dbafcdcba3bc270e7
        http://127.0.0.1:8888/lab?token=6b54a68b3230f79b6f719f36cdfd9e3dbafcdcba3bc270e7
[I 2025-01-15 18:44:10.561 ServerApp] Skipped non-installed server(s): bash-language-server, dockerfile-language-server-nodejs, javascript-typescript-langserver, jedi-language-server, julia-language-server, pyright, python-language-server, python-lsp-server, r-languageserver, sql-language-server, texlab, typescript-language-server, unified-language-server, vscode-css-languageserver-bin, vscode-html-languageserver-bin, vscode-json-languageserver-bin, yaml-language-server
[W 2025-01-15 18:44:12.203 LabApp] Could not determine jupyterlab build status without nodejs
[W 2025-01-15 18:44:52.720 ServerApp] 404 GET /api/collaboration/room/JupyterLab:globalAwareness ([email protected]) 39.53ms referer=None
[I 2025-01-15 18:45:03.006 ServerApp] Creating new notebook in 
[W 2025-01-15 18:45:03.095 ServerApp] 404 PUT /api/collaboration/session/Untitled.ipynb?1736963103090 ([email protected]) 1.33ms referer=http://localhost:8888/lab
[W 2025-01-15 18:45:52.743 ServerApp] 404 GET /api/collaboration/room/JupyterLab:globalAwareness ([email protected]) 1.03ms referer=None
[W 2025-01-15 18:46:52.756 ServerApp] 404 GET /api/collaboration/room/JupyterLab:globalAwareness ([email protected]) 3.77ms referer=None
w[W 2025-01-15 18:47:52.971 ServerApp] 404 GET /api/collaboration/room/JupyterLab:globalAwareness ([email protected]) 3.24ms referer=None
[W 2025-01-15 18:48:52.983 ServerApp] 404 GET /api/collaboration/room/JupyterLab:globalAwareness ([email protected]) 3.23ms referer=None
[W 2025-01-15 18:49:53.027 ServerApp] 404 GET /api/collaboration/room/JupyterLab:globalAwareness ([email protected]) 3.63ms referer=None

Jupyter version:

$ jupyter --version
Selected Jupyter core packages...
IPython          : 8.31.0
ipykernel        : 6.29.5
ipywidgets       : not installed
jupyter_client   : 8.6.3
jupyter_core     : 5.7.2
jupyter_server   : 2.15.0
jupyterlab       : 4.3.4
nbclient         : 0.10.2
nbconvert        : 7.16.5
nbformat         : 5.10.4
notebook         : not installed
qtconsole        : not installed
traitlets        : 5.14.3

I get the same error when i run jupyter-notebook outside of a virtualenv, and I'm still unable to run any notebook.

I don't think it comes from the jupyter installation because I get the same result on multiple installations. I was also able to run jupyterlab in a docker container.


Solution

  • I had the same problem after upgrading my system.

    In my case, the solution was to remove configurations and data that Jupyter had stored at a couple of places throughout the system.

    First, check which paths Jupyter is potentially using:

    $> venv/bin/jupyter --paths
    config:
        ./venv/etc/jupyter
        /home/<USER>/.jupyter
        /usr/local/etc/jupyter
        /etc/jupyter
    data:
        ./venv/share/jupyter
        /home/<USER>/.local/share/jupyter
        /usr/local/share/jupyter
        /usr/share/jupyter
    runtime:
        /home/<USER>/.local/share/jupyter/runtime
    

    Some of these paths might not exist, so that you do not need to handle them. Others might have the actual configuration and data that you intend to use (in my case, this is the virtual environment at ./venv/).

    Next, (re)move those directories that might contain outdated information, e.g.,

    mv /home/<USER>/.jupyter /home/<USER>/.jupyter.bck # keep as a backup
    sudo mv /usr/share/jupyter /usr/share/jupyter.bck
    

    Moving the configuration directories resolved some peculiar but harmless warnings that I had. Moving the data directories resolved the 404 issue and allowed me to open my notebooks again. I did not touch the runtime directory.

    Please let me know if this approach works for you; we can later update this answer to keep it for later reference.