0

I am trying to connect to remote jupyter server which is running in remote server inside a docker. from vs code (local machine) with the help of jupyter extension, and running a newly created notebook. The problem seems to be the kernel creation via this method for this newly created notebook.

My Jupyter Server is running in remote server, inside a docker environment, with port forwarding enable. I can access it via my browser by http://{remote_machine_ip}:{port}/, and I am able to create new jupyter notebook. However when I use the vs code to open local notebook file, and connect to the remote jupyter server. When I try to run the cells, it shows the following error:

Failed to start the Kernel. 
'_xsrf' argument missing from POST. 
View Jupyter log for further details.

Possible solution However, if I try to open a new kernel in browser, and connect it to same kernel in vs code, the problem goes away.

  • I have the same problem when using aws-glue-libs:glue_libs_4.0.0_image_01. Via browser it works fine, via vsc I'm getting the same error. Moreover your possible solution does not work for me. – saif3r Feb 09 '23 at 10:50
  • If for some reason your kernel becomes dead, while running code in vcs. Then the problem will still persist. So, you need to open the notebook again in browser, it will create new kernel, then you can run the cells, in notebook. Just make sure, your kernel is up when connecting to remote server for a particular notebook. – Lokesh Kurre Feb 09 '23 at 14:06
  • Thanks. My kernel is definitely up, as it works without disruption in the browser. Unfortunately in VSC, it does not. – saif3r Feb 09 '23 at 14:37
  • You are picking up the same kernel in kernel picker in vscode, right? top right corner, where it show the list of kernel, when connected to remote jupyter server – Lokesh Kurre Feb 09 '23 at 17:02

1 Answers1

0

This issue seems to be arising when vs code sends the request to create jupyter kernel to the jupyter server. As, when I tested with already running jupyter kernel in vs code, it works fine.

The issue here is, security implementation of jupyter server, which don't allow cross site request to create a kernel, as it security vulnerability.

For more details about _xsrf token, you can read here, although it doesn't talk about specific to jupyter server, its very easy to deduce the logic.

In one post of jetbrains, I found the solution, to make jupyter ignore _xsrf token, by adding new flag while starting the jupyter server,

--NotebookApp.disable_check_xsrf=True

Or add it to your notebook config. Also, to make sure your request are not been blocked, as suggested by vscode blog. Add the following flag too,

--NotebookApp.allow_origin='*'