# Error 'AttributeError: 'NoneType' object has no attribute 'kernel\_ws\_protocol''

**URL:** <https://discourse.jupyter.org/t/error-attributeerror-nonetype-object-has-no-attribute-kernel-ws-protocol/22450>\
**Category:** General\
**Tags:** help-wanted\
**Created:** [November 17, 2023, 11:36am UTC](https://discourse.jupyter.org/t/error-attributeerror-nonetype-object-has-no-attribute-kernel-ws-protocol/22450 "2023-11-17T11:36:33Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![romangershgorin](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/romangershgorin/32/11631_2.png) [@romangershgorin](https://discourse.jupyter.org/u/romangershgorin)\
**Post date:** [November 17, 2023, 11:36am UTC](https://discourse.jupyter.org/t/error-attributeerror-nonetype-object-has-no-attribute-kernel-ws-protocol/22450/1 "2023-11-17T11:36:33Z")

</div>

Hello, we have internal instance of Jupyterlab, running on k8s cluster. After the moment I open UI, I usually experience several consecutive errors like:

```auto
[E 2023-11-17 12:07:44.475 ServerApp] 500 GET <some_path>/jupyter/api/kernels/153ad49f-6d1f-4f68-aa44-1e848b2b2dd7/channels?session_id=c3780625-5bd9-42cd-9a02-2a6dc46e3749 (266b9f0237614ad6885dbb74d6558310@10.218.43.180) 33668.23ms referer=None
[E 2023-11-17 12:07:44.476 ServerApp] Uncaught exception GET <some_path>/jupyter/api/kernels/153ad49f-6d1f-4f68-aa44-1e848b2b2dd7/channels?session_id=c3780625-5bd9-42cd-9a02-2a6dc46e3749 (10.197.217.112)
    HTTPServerRequest(protocol='http', host='<some_host>:8080', method='GET', uri='<some_path>/jupyter/api/kernels/153ad49f-6d1f-4f68-aa44-1e848b2b2dd7/channels?session_id=c3780625-5bd9-42cd-9a02-2a6dc46e3749', version='HTTP/1.1', remote_ip='10.197.217.112')
    Traceback (most recent call last):
      File "/opt/spark/work-dir/miniconda3/lib/python3.10/site-packages/tornado/web.py", line 1786, in _execute
        result = await result
      File "/opt/spark/work-dir/.local/lib/python3.10/site-packages/jupyter_server/services/kernels/websocket.py", line 65, in get
        await super().get(kernel_id=kernel_id)
      File "/opt/spark/work-dir/miniconda3/lib/python3.10/site-packages/tornado/websocket.py", line 272, in get
        await self.ws_connection.accept_connection(self)
      File "/opt/spark/work-dir/miniconda3/lib/python3.10/site-packages/tornado/websocket.py", line 862, in accept_connection
        await self._accept_connection(handler)
      File "/opt/spark/work-dir/miniconda3/lib/python3.10/site-packages/tornado/websocket.py", line 902, in _accept_connection
        self.selected_subprotocol = handler.select_subprotocol(subprotocols)
      File "/opt/spark/work-dir/.local/lib/python3.10/site-packages/jupyter_server/services/kernels/websocket.py", line 87, in select_subprotocol
        preferred_protocol = self.connection.kernel_ws_protocol
    AttributeError: 'NoneType' object has no attribute 'kernel_ws_protocol'

```

After those websocket is being opened and no further errors occure, nor any issues with functionality of jupyterlab I can detect:

```auto
[E 2023-11-17 12:07:44.477 ServerApp] 500 GET <some_path>/jupyter/api/kernels/153ad49f-6d1f-4f68-aa44-1e848b2b2dd7/channels?session_id=c3780625-5bd9-42cd-9a02-2a6dc46e3749 (2367bf49cb2f4e97a05df0b79a8909ea@10.197.217.112) 28037.39ms referer=None
[D 2023-11-17 12:07:44.477 ServerApp] 101 GET <some_path>/jupyter/api/kernels/153ad49f-6d1f-4f68-aa44-1e848b2b2dd7/channels?session_id=c3780625-5bd9-42cd-9a02-2a6dc46e3749 (2367bf49cb2f4e97a05df0b79a8909ea@10.197.217.112) 2884.24ms
[D 2023-11-17 12:07:44.477 ServerApp] Opening websocket <some_path>/jupyter/api/kernels/153ad49f-6d1f-4f68-aa44-1e848b2b2dd7/channels

```

I failed so far to locate the root-cause of this error, if anybody has any ideas on what can cause it, the help is greatly appreciated.

---

<div class="post-metadata">

**Author:** ![krassowski](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/krassowski/32/1685_2.png) [@krassowski](https://discourse.jupyter.org/u/krassowski)\
**Post date:** [November 17, 2023, 11:45am UTC](https://discourse.jupyter.org/t/error-attributeerror-nonetype-object-has-no-attribute-kernel-ws-protocol/22450/2 "2023-11-17T11:45:52Z")

</div>

This looks like incompatibility in some package versions. Can you run `pip check` (assuming you use pip not conda) and `jupyter --version` and report the outputs?

---

<div class="post-metadata">

**Author:** ![krassowski](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/krassowski/32/1685_2.png) [@krassowski](https://discourse.jupyter.org/u/krassowski)\
**Post date:** [November 17, 2023, 11:46am UTC](https://discourse.jupyter.org/t/error-attributeerror-nonetype-object-has-no-attribute-kernel-ws-protocol/22450/3 "2023-11-17T11:46:42Z")

</div>

It was also reported in ['NoneType' object has no attribute 'kernel\_ws\_protocol' · Issue #1265 · jupyter-server/jupyter\_server · GitHub](https://github.com/jupyter-server/jupyter_server/issues/1265).

---

<div class="post-metadata">

**Author:** ![romangershgorin](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/romangershgorin/32/11631_2.png) [@romangershgorin](https://discourse.jupyter.org/u/romangershgorin)\
**Post date:** [November 17, 2023, 12:54pm UTC](https://discourse.jupyter.org/t/error-attributeerror-nonetype-object-has-no-attribute-kernel-ws-protocol/22450/4 "2023-11-17T12:54:17Z")

</div>

Thanks for your answer, here is the output of these commands

```auto
bash-4.2$ which pip3
/opt/spark/work-dir/miniconda3/bin/pip3
bash-4.2$ pip3 check
conda 23.10.0 has requirement ruamel-yaml<0.18,>=0.11.14, but you have ruamel-yaml 0.18.5.
bash-4.2$ jupyter --version
Selected Jupyter core packages...
IPython : 8.17.2
ipykernel : 6.26.0
ipywidgets : not installed
jupyter_client : 8.6.0
jupyter_core : 5.5.0
jupyter_server : 2.10.1
jupyterlab : 4.0.8
nbclient : 0.9.0
nbconvert : 7.11.0
nbformat : 5.9.2
notebook : not installed
qtconsole : not installed
traitlets : 5.13.0
bash-4.2$ which pip
/opt/spark/work-dir/miniconda3/bin/pip
bash-4.2$ pip check
conda 23.10.0 has requirement ruamel-yaml<0.18,>=0.11.14, but you have ruamel-yaml 0.18.5.

```

---

<div class="post-metadata">

**Author:** ![romangershgorin](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/romangershgorin/32/11631_2.png) [@romangershgorin](https://discourse.jupyter.org/u/romangershgorin)\
**Post date:** [November 20, 2023, 12:29pm UTC](https://discourse.jupyter.org/t/error-attributeerror-nonetype-object-has-no-attribute-kernel-ws-protocol/22450/5 "2023-11-20T12:29:34Z")

</div>

Asked here as well, no solution was found so far

---

<div class="post-metadata">

**Author:** ![Zhijun\_Yu](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/zhijun_yu/32/12345_2.png) [@Zhijun\_Yu](https://discourse.jupyter.org/u/Zhijun_Yu)\
**Post date:** [February 7, 2024, 9:35pm UTC](https://discourse.jupyter.org/t/error-attributeerror-nonetype-object-has-no-attribute-kernel-ws-protocol/22450/6 "2024-02-07T21:35:47Z")

</div>

Hello!  
Recently I encountered the same error, did you found solutions?  
I also have this error:`tornado.websocket.WebSocketClosedError`  
I have the error only when I want to connect Jupyter with my conda R env. my conda python envs are perfectly fine with Jupiyter.  
I am already trouble shooting for few days, no luck yet.

---

<div class="post-metadata">

**Author:** ![romangershgorin](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/romangershgorin/32/11631_2.png) [@romangershgorin](https://discourse.jupyter.org/u/romangershgorin)\
**Post date:** [February 8, 2024, 7:19am UTC](https://discourse.jupyter.org/t/error-attributeerror-nonetype-object-has-no-attribute-kernel-ws-protocol/22450/7 "2024-02-08T07:19:42Z")

</div>

Hi, unfortunately I still have no solution for this issue

---

<div class="post-metadata">

**Author:** ![Zhijun\_Yu](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/zhijun_yu/32/12345_2.png) [@Zhijun\_Yu](https://discourse.jupyter.org/u/Zhijun_Yu)\
**Post date:** [February 8, 2024, 9:30am UTC](https://discourse.jupyter.org/t/error-attributeerror-nonetype-object-has-no-attribute-kernel-ws-protocol/22450/8 "2024-02-08T09:30:50Z")

</div>

Hi  
Thanks for the reply.  
Now I change to vs-code, the jupyter works there.
