# Websocket connection errors when connecting to Kernel (from desktop app) started in Docker

**URL:** <https://discourse.jupyter.org/t/websocket-connection-errors-when-connecting-to-kernel-from-desktop-app-started-in-docker/27244>\
**Category:** JupyterHub\
**Tags:** jupyterlab\
**Created:** [July 29, 2024, 2:17am UTC](https://discourse.jupyter.org/t/websocket-connection-errors-when-connecting-to-kernel-from-desktop-app-started-in-docker/27244 "2024-07-29T02:17:02Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![DonJayamanne](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/donjayamanne/32/4634_2.png) [@DonJayamanne](https://discourse.jupyter.org/u/DonJayamanne)\
**Post date:** [July 29, 2024, 2:17am UTC](https://discourse.jupyter.org/t/websocket-connection-errors-when-connecting-to-kernel-from-desktop-app-started-in-docker/27244/1 "2024-07-29T02:17:02Z")

</div>

- Start Jupyter hub from here [jupyterhub/jupyterhub-deploy-docker: Reference deployment of JupyterHub with docker (github.com)](https://github.com/jupyterhub/jupyterhub-deploy-docker)
- Connect to Jupyter Hub from the browser for user `admin`
- Spawn a server and created a token using the `Hub Panel`
- At this point we’re able to create Notebooks and start kernels/execute code, everything works
- Open Postman and create a new Jupyter Session with the URL `http://localhost:8000/user/admin/api/sessions` and JSON payload as

```json
{"path":"sample.ipynb","kernel":{"name":"python3"},"name":"sample.ipynb","type":"notebook"}

```

and provide the token as auth header.  
The response is a status of 201 and here’s the JSON result sent back

```json
{
    "id": "d3ed6681-877d-4f03-9d78-8232616d4cc3",
    "path": "sample.ipynb",
    "name": "sample.ipynb",
    "type": "notebook",
    "kernel": {
        "id": "30fa12d7-9448-4189-b496-ffb0e11869a2",
        "name": "python3",
        "last_activity": "2024-07-29T00:43:27.178067Z",
        "execution_state": "starting",
        "connections": 0
    },
    "notebook": {
        "path": "sample.ipynb",
        "name": "sample.ipynb"
    }
}

```

Attempt to connect to the above Kernel WebSocket using node.js or the like (outside the browser), and we get a 403 error.  
Here’s the sample (details might not match above response) Url for the WebSocket (which container the token as well):

```auto
ws://localhost:8000/user/admin/api/kernels/4323f636-f3db-4e01-834f-27f49cd80d09/channels?session_id=f704194e-5ba3-4508-abbe-b062a0e1cde3&token=6bb55cbea7054d92a2a40e146fff86c2

```

I suspect this has something to do with some configuration settings in Jupyter Lab spawned within the container. Not sure.  
I’ve also tried adding the following config into the `jupyterhub_config.py` file, without any luck

```auto
c.DockerSpawner.args = [
    "--debug",
    "--ServerApp.allow_origin='*'",
    "--ServerApp.allow_remote_access=True",
]

```

---

<div class="post-metadata">

**Author:** ![DonJayamanne](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/donjayamanne/32/4634_2.png) [@DonJayamanne](https://discourse.jupyter.org/u/DonJayamanne)\
**Post date:** [July 31, 2024, 7:04am UTC](https://discourse.jupyter.org/t/websocket-connection-errors-when-connecting-to-kernel-from-desktop-app-started-in-docker/27244/2 "2024-07-31T07:04:15Z")

</div>

Figure out that the authorization header was not set in the WebSocket.
