Cannot connect to Jupyter notebook server running on Xubuntu inside VirtualBox

匿名 (未验证) 提交于 2019-12-03 00:58:01

问题:

I have a recent install of Jupyter running on Xubunut inside VirtualBox.

I have no problems accessing it within the guest.

Copy/paste this URL into your browser when you connect for the first time, to login with a token:      http://localhost:8888/?token=e7e0676d331f8c7a52cd8918217d51496c2b38cc1aa1c107 

However, I cannot get this URL to work from my host environment, Windows 10.

At first, I thought there must be some problem with port forwarding, so I installed openssh-server to test. Much of the advice I've found said that the guest IP should be left blank in the VBox port forwarding configuration, but I found that I needed to add the guest IP. Once I added the guest IP to the port forwarding line for SSH, Putty to localhost:22 began working.

However, browsing to the Jupyter notebook still fails. Interesting, it does not fail slowly (as would be expected with a failure to find the host), but instantly with The site can't be reached ERR_SOCKET_NOT_CONNECTED.

This must be related to the fact that Jupyter only accepts localhost connections.

If I try from the guest:

http://10.0.2.15:8888/?token=8543227ac6d6483ba4aac4c55b4b041282d3e540012f9aec 

The connection fails. Jupyter does not log anything about receiving a connection. I already have debugging enabled. Can I increase the level of debugging to get Jupyter to tell me why it did not accept that connection?

If I try from the guest:

http://127.0.0.1:8888/?token=8543227ac6d6483ba4aac4c55b4b041282d3e540012f9aec 

It connects

[D 07:37:23.544 NotebookApp] Accepting token-authenticated connection from 127.0.0.1 

So, I figured the connection needs to appear to be coming from 127.0.0.1 for Jupyter to accept it. I set the guest IP address to 127.0.0.1 in VBox port forwarding. Now I get ERR_CONNECTION_RESET instead of the socket error above. This is more like the error I get when port forwarding is not working at all.

I'm at a loss now. Can you tell me what I've missed in this setup?

回答1:

I was just trying to do this as well, and having basically the same problem. You said

This must be related to the fact that Jupyter only accepts localhost connections.

Ok, I can work around that, and here is how: Since you have putty working, if you set up a tunnel, then you can access it from another machine as if you were on localhost.

Open Putty put in your server address (or load saved) like you normally would to connect, and then on the left menu expand Connection, expand SSH, and click on SSH.

In this area on the right under Protocol options, tick the option Don't start a shell or command at all.

On the left go to Tunnels under SSH and in the Source port box put in 8888, the default port for Jupyter. In the Destination box put in 127.0.0.1:8888. Click the Add button

Next click Open to start your connection -- You'll get the standard SSH login, with the exception of the screen will seem to just be dead after logging in, this is to be expected and is normal, due to the Don't start a shell or command at all option.

At this point, you should be able to open your browser and navigate to http://127.0.0.1:8888/?token=8543227ac6d6483ba4aac4c55b4b041282d3e540012f9aec, or whatever url you are given on the guest.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!