# Cant connect to kernel

**URL:** <https://discourse.jupyter.org/t/cant-connect-to-kernel/24705>\
**Category:** JupyterHub\
**Tags:** help-wanted\
**Created:** [March 22, 2024, 11:25am UTC](https://discourse.jupyter.org/t/cant-connect-to-kernel/24705 "2024-03-22T11:25:06Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![guyq1997](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/guyq1997/32/12306_2.png) [@guyq1997](https://discourse.jupyter.org/u/guyq1997)\
**Post date:** [March 22, 2024, 11:25am UTC](https://discourse.jupyter.org/t/cant-connect-to-kernel/24705/1 "2024-03-22T11:25:06Z")

</div>

Hello guys,  
I am using Apache as reverseproxy.

> \<Location /jupyterhub\>
> 
> ```
> RequestHeader unset Accept-Encoding
> ProxyPass http://jupyterhub:8000/jupyterhub
> ProxyPassReverse http://jupyterhub:8000/jupyterhub
> 
> RewriteEngine On
> ProxyPreserveHost on
> 
> AuthType shibboleth
> ShibRequestSetting requireSession 1
> Require valid-user
> ShibUseHeaders On
> RequestHeader set X-Remote-User %{REMOTE_USER}s
> 
> ```
> 
> This error occurs in my single user server

And This is my Jupyterhub\_config.py

> c.Spawner.cmd = “jupyterhub-singleuser”  
> c.Spawner.debug = True  
> c.ConfigurableHTTPProxy.debug = True  
> c.DockerSpawmer.use\_internal\_ip = True  
> c.JupyterHub.spawner\_class = DockerSpawner  
> c.DockerSpawner.image = “xxx/jupyterlab”
> 
> c.JupyterHub.hub\_ip = “0.0.0.0”  
> c.JupyterHub.bind\_url = ‘http://:8000/jupyterhub’
> 
> c.DockerSpawner.network\_name = os.environ[“DOCKER\_NETWORK\_NAME”]  
> c.DockerSpawner.extra\_host\_config = { ‘network\_mode’: os.environ[“DOCKER\_NETWORK\_NAME”] }  
> c.DockerSpawner.remove\_containers = True  
> c.DockerSpawner.start\_timeout = 120  
> c.JupyterHub.authenticator\_class = ShibbolethAuthenticator

I can spawn and access Single user server, but i cant open a notebook and connect to kernel. The Eorror Code:

> [W 2024-03-22 11:18:42.287 ServerApp] 400 GET /jupyterhub/user/yuqiang/api/events/subscribe?token=[secret] (yuqiang@::ffff:172.20.0.3) 2.13ms
> 
> [W 2024-03-22 11:18:49.038 ServerApp] 400 GET /jupyterhub/user/yuqiang/api/events/subscribe?token=[secret] (yuqiang@::ffff:172.20.0.3) 1.76ms

---

<div class="post-metadata">

**Author:** ![guyq1997](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/guyq1997/32/12306_2.png) [@guyq1997](https://discourse.jupyter.org/u/guyq1997)\
**Post date:** [March 22, 2024, 1:27pm UTC](https://discourse.jupyter.org/t/cant-connect-to-kernel/24705/2 "2024-03-22T13:27:59Z")

</div>

I found a not fancy solution in my case.  
I manually redirect this failed request in Apache proxy like this:

```auto
        <Location "/jupyterhub/***[username]***/api/kernels">
            ProxyPass ws://localhost:8000/jupyterhub/***[username]***/api/kernels
            ProxyPassReverse ws://localhost:8000/jupyterhub/***[username]***/api/kernels
        </Location>

```

But it is really dumm, that, i have to add this code for all 30 users. (for every _ **username** _)  
Is there any better way to automatically redirect this request, like Regular expression?

---

<div class="post-metadata">

**Author:** ![mahendrapaipuri](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/mahendrapaipuri/32/6800_2.png) [@mahendrapaipuri](https://discourse.jupyter.org/u/mahendrapaipuri)\
**Post date:** [March 22, 2024, 1:39pm UTC](https://discourse.jupyter.org/t/cant-connect-to-kernel/24705/3 "2024-03-22T13:39:41Z")

</div>

Here is a reference Apache proxy config that should work with JupyterHub → [Using a reverse proxy — JupyterHub documentation](https://jupyterhub.readthedocs.io/en/stable/howto/configuration/config-proxy.html#apache)

I guess you are missing webscokets connection upgrade directives in your config

---

<div class="post-metadata">

**Author:** ![guyq1997](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/guyq1997/32/12306_2.png) [@guyq1997](https://discourse.jupyter.org/u/guyq1997)\
**Post date:** [March 22, 2024, 3:21pm UTC](https://discourse.jupyter.org/t/cant-connect-to-kernel/24705/4 "2024-03-22T15:21:00Z")

</div>

Hi,

Thanks. You are right! I just missed the websockets upgrade part!  
I can now acess to my content. But It starts to restart my single user server all the time.  
 ![image](https://canada1.discourse-cdn.com/flex031/uploads/jupyter/original/2X/d/d7ff83ad104b21471ec5477f2a0ccefbdedd2bc7.png)

And in Logs i found this:

> 15:22:57.392 [ConfigProxy] debug: Not recording activity for status 304 on /jupyterhub/user/yuqiang  
> 15:22:57.393 [ConfigProxy] debug: Not recording activity for status 304 on /jupyterhub/user/yuqiang  
> 15:22:57.395 [ConfigProxy] debug: Not recording activity for status 304 on /jupyterhub/user/yuqiang  
> 15:22:57.397 [ConfigProxy] debug: Not recording activity for status 304 on /jupyterhub/user/yuqiang  
> 15:22:57.399 [ConfigProxy] debug: Not recording activity for status 304 on /jupyterhub/user/yuqiang

---

<div class="post-metadata">

**Author:** ![guyq1997](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/guyq1997/32/12306_2.png) [@guyq1997](https://discourse.jupyter.org/u/guyq1997)\
**Post date:** [March 26, 2024, 4:20pm UTC](https://discourse.jupyter.org/t/cant-connect-to-kernel/24705/6 "2024-03-26T16:20:45Z")

</div>

**Another Problem:**  
And strange things happen, if I activate the Jupyter-collaboration extension.  
I can normally open a notebook in my home directory (/home/joyvan)  
But can not connect to Kernel and open a notebook in a folder (/home/joyvan/[some newfolder]).

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/jupyter/original/2X/b/b348cce191ff0430900ec1f67ed712405126cd3d.png)

**The Cause according my guess:**  
This Problem doesn´t exsit if i only use Jupyterhub internal Proxy (CHP). So I guess the problem is the compatibility of Jupyter-collaboration extension and Apache2?

Logs seem good:

> [I 2024-03-26 16:26:47.448 ServerApp] 200 GET /jupyterhub/user/yuqiang/api/contents/Untitled%20Folder?content=1&1711470407345 ([yuqiang@172.22.0.4](mailto:yuqiang@172.22.0.4)) 4.89ms  
> [I 2024-03-26 16:26:50.123 ServerApp] 200 GET /jupyterhub/user/yuqiang/api (@172.22.0.5) 0.78ms  
> [I 2024-03-26 16:26:52.162 YDocExtension] Processed 366 Y patches in one minute  
> [I 2024-03-26 16:26:52.162 YDocExtension] Connected Y users: 8  
> [I 2024-03-26 16:26:52.563 ServerApp] 200 GET /jupyterhub/user/yuqiang/api/terminals?1711470412349 ([yuqiang@172.22.0.4](mailto:yuqiang@172.22.0.4)) 2.14ms  
> [I 2024-03-26 16:26:52.749 ServerApp] 200 GET /jupyterhub/user/yuqiang/api/me?1711470412533 ([yuqiang@172.22.0.4](mailto:yuqiang@172.22.0.4)) 1.96ms  
> [I 2024-03-26 16:26:52.771 ServerApp] 200 GET /jupyterhub/user/yuqiang/api/kernelspecs?1711470412535 ([yuqiang@172.22.0.4](mailto:yuqiang@172.22.0.4)) 2.58ms  
> [I 2024-03-26 16:26:55.327 ServerApp] 200 GET /jupyterhub/user/yuqiang/api (@172.22.0.5) 0.78ms

---

<div class="post-metadata">

**Author:** ![manics](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/manics/32/85_2.png) [@manics](https://discourse.jupyter.org/u/manics)\
**Post date:** [March 26, 2024, 4:40pm UTC](https://discourse.jupyter.org/t/cant-connect-to-kernel/24705/7 "2024-03-26T16:40:58Z")

</div>

What do your browser console logs ([https://help.zapier.com/hc/en-us/articles/8496199434765-View-and-save-your-browser-console-logs](https://help.zapier.com/hc/en-us/articles/8496199434765-View-and-save-your-browser-console-logs)) and Apache logs show?

---

<div class="post-metadata">

**Author:** ![guyq1997](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/guyq1997/32/12306_2.png) [@guyq1997](https://discourse.jupyter.org/u/guyq1997)\
**Post date:** [March 26, 2024, 4:57pm UTC](https://discourse.jupyter.org/t/cant-connect-to-kernel/24705/8 "2024-03-26T16:57:46Z")

</div>

There is Error in **Browser Logs**!:

![image](https://canada1.discourse-cdn.com/flex031/uploads/jupyter/original/2X/a/a42ab82a71bbce2d13974ccab574c014301fe387.png)

![image](https://canada1.discourse-cdn.com/flex031/uploads/jupyter/original/2X/3/37267bb97c9d5fc965bc2c126390fafab10a86d8.png)

![image](https://canada1.discourse-cdn.com/flex031/uploads/jupyter/original/2X/5/5f8bc0d14c72a949982329fbf1730154ca9ff2b1.png)

There is nothing strange accrodding to **Apache Logs:**

[26/Mar/2024:16:43:14 +0000] “GET /jupyterhub/user/yuqiang/api/terminals?1711471394311 HTTP/1.1” 200 823 “https:///jupyterhub/user/yuqiang/lab/tree/RTC%3AUntitled%20Folder/Untitled.ipynb” "

[26/Mar/2024:16:43:14 +0000] “GET /jupyterhub/user/yuqiang/api/contents/Untitled%20Folder?content=1&1711471394574 HTTP/1.1” 200 1093 “https:///jupyterhub/user/yuqiang/lab/tree/RTC%3AUntitled%20Folder/Untitled.ipynb”

[26/Mar/2024:16:43:14 +0000] “GET /jupyterhub/user/yuqiang/api/kernels?1711471394421 HTTP/1.1” 200 3475 “https:///jupyterhub/user/yuqiang/lab/tree/RTC%3AUntitled%20Folder/Untitled.ipynb” “Mozilla/5.0 (iPhone; CPU iPhone OS 17\_2\_1 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/17.2 Mobile/15E148 Safari/604.1”

---

<div class="post-metadata">

**Author:** ![guyq1997](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/guyq1997/32/12306_2.png) [@guyq1997](https://discourse.jupyter.org/u/guyq1997)\
**Post date:** [March 27, 2024, 12:07pm UTC](https://discourse.jupyter.org/t/cant-connect-to-kernel/24705/9 "2024-03-27T12:07:34Z")

</div>

The **problematic error Log** is likely this: Browser fails to find the URL of directory ([https://jupyterhub//user/yuqiang/api/collaboration/session/Untitled%20Folder%2FUntitled1.ipynb?1711541015975](https://jupyterhub//user/yuqiang/api/collaboration/session/Untitled%20Folder%2FUntitled1.ipynb?1711541015975))

![image](https://canada1.discourse-cdn.com/flex031/uploads/jupyter/original/2X/b/bfc81b8b7336d99b7cea01ec2d6f33d33b248b50.png)

And again, this problem doesn´t exist if a disable the _ **jupyter-collaboration** _ extention.

---

<div class="post-metadata">

**Author:** ![guyq1997](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/guyq1997/32/12306_2.png) [@guyq1997](https://discourse.jupyter.org/u/guyq1997)\
**Post date:** [March 28, 2024, 3:46pm UTC](https://discourse.jupyter.org/t/cant-connect-to-kernel/24705/10 "2024-03-28T15:46:42Z")

</div>

A new version of Jupyterlab==4.1.5 also doesn´t help.

I found that the single user server and my browser are opening different URL. Single user server found the right url but My Browser doesn´t.

Browser says it can´t open the Note book because following URL doesn´t exist

> /user/yuqiang/api/collaboration/session/Assignment%2FVisualisierung\_CO2\_Konzentration.ipynb 404 (Not Found)

Single user Server says that, it can successfully access to it:

> [I 2024-03-28 15:41:38.678 YDocExtension] Processed 53 Y patches in one minute  
> [I 2024-03-28 15:41:38.678 YDocExtension] Connected Y users: 3  
> [I 2024-03-28 15:41:40.648 ServerApp] 200 GET /jupyterhub/user/yuqiang/api/contents/Assignment/Visualisierung\_CO2\_Konzentration.ipynb?type=notebook&content=0 (yuqiang@::ffff:172.31.0.3) 3.34ms

---

<div class="post-metadata">

**Author:** ![guyq1997](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/guyq1997/32/12306_2.png) [@guyq1997](https://discourse.jupyter.org/u/guyq1997)\
**Post date:** [April 8, 2024, 9:16pm UTC](https://discourse.jupyter.org/t/cant-connect-to-kernel/24705/11 "2024-04-08T21:16:37Z")

</div>

I found the problematic Request is sent by Apache Webserver. The Request sent by Apche seems to be blocked. Other Requests, which are sent by tornado, are no problem.

Any suggestions to let tornado send the request instead of Apache?

 ![image](https://canada1.discourse-cdn.com/flex031/uploads/jupyter/original/2X/8/800961a0179798eaac680294a617c6c944d399bb.png)

---

<div class="post-metadata">

**Author:** ![minrk](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/minrk/32/13_2.png) [@minrk](https://discourse.jupyter.org/u/minrk)\
**Post date:** [April 10, 2024, 9:01am UTC](https://discourse.jupyter.org/t/cant-connect-to-kernel/24705/12 "2024-04-10T09:01:03Z")

</div>

I’m not entirely sure what’s going on here, but if Apache is responding, this means that some routing rule in Apache is not forwarding the request to JupyterHub. That should all be in the apache config, since it means JupyterHub hasn’t had a chance to doesn’t get involved.

Since it’s a subset of URLs, I wonder if some other config is catching URLs with e.g. `session` in them.

Another possible option that I’m not sure about is a version mismatch in the jupyter-collaboration javascript and Python versions. Making sure both are up to date and restarting the server _might_ help.

If you request a URL that definitely 404s and will be served by JupyterLab: /jupyterhub/user/yuqiang/api/nosuchthing/should/404

do you see it served by Apache or Tornado?

---

<div class="post-metadata">

**Author:** ![guyq1997](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/guyq1997/32/12306_2.png) [@guyq1997](https://discourse.jupyter.org/u/guyq1997)\
**Post date:** [April 12, 2024, 1:30pm UTC](https://discourse.jupyter.org/t/cant-connect-to-kernel/24705/13 "2024-04-12T13:30:17Z")

</div>

Hello @minrk ,

I am using python ==3.11.6 and jupyter-collaboration==2.0.11.

If i request URL [eample.org/jupyterhub/user/yuqiang/api/nosuchthing/should/404](http://eample.org/jupyterhub/user/yuqiang/api/nosuchthing/should/404), which is 404. It is served by Tornado.

---

<div class="post-metadata">

**Author:** ![guyq1997](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/guyq1997/32/12306_2.png) [@guyq1997](https://discourse.jupyter.org/u/guyq1997)\
**Post date:** [April 15, 2024, 8:16am UTC](https://discourse.jupyter.org/t/cant-connect-to-kernel/24705/14 "2024-04-15T08:16:09Z")

</div>

Tornado will serve the following URL  
_/jupyterhub/user/udo.heuser/api/collaboration/session/Assignment_  
But not  
_/jupyterhub/user/udo.heuser/api/collaboration/session/Assignment%2F…_  
I got a Apache error with this URL  
 ![image](https://canada1.discourse-cdn.com/flex031/uploads/jupyter/original/2X/f/fce491292f9ea9e01839b184621b2b919914514d.png)

Where Assignment is a directory in my workspace

So I think the **%2F** or **%** is the problem, that makes Apache confused, and Tornado can´t recive the request.

---

<div class="post-metadata">

**Author:** ![guyq1997](https://yyz1.discourse-cdn.com/flex031/user_avatar/discourse.jupyter.org/guyq1997/32/12306_2.png) [@guyq1997](https://discourse.jupyter.org/u/guyq1997)\
**Post date:** [April 15, 2024, 8:29am UTC](https://discourse.jupyter.org/t/cant-connect-to-kernel/24705/15 "2024-04-15T08:29:40Z")

</div>

Problem solved!  
Add this to Apache confiiguration. If you want to use jupyter-collaboration with Apache as reverse proxy!

```auto
AllowEncodedSlashes On  

```
