2

I have a linux server. On that I have installed Miniconda3 and other python packages along with Jupyter.

Now I want to run the notebook on the server and open in my browser.

For that, after installation of all packages, I do:

user@remoteip:$ jupyter notebook --no-browser --port=8890

Now I am copying the server IP address along with port to open it in my local browser.

http://remoteip:8890

However it doesn't open up anything.

I then followed all suggestions given in this SO answer by adding the required statements in the configuration file on the remote server anaconda and even local anaconda jupyter config file.

But it doesn't help at all.

After that I had to port forwarding as below in my local terminal:

user@localhost: ssh -N -f -L localhost:8890:localhost:8890 user@remoteip

And after that when I open

localhost:8890 

now it opens up the notebook requiring the token to be entered and then it works.

My question is that do we need to do port forwarding everytime for us to open a notebook on remote server? One of my colleague said he didn't do any port forwarding and after first step itself, he was able to open the notebook with by typing

http://remoteip:8890

So I am not sure we need to do port forwarding for us to open the server jupyter notebook to open in browser or we can directly open the notebook with remoteip address?

Edit:

As per Alex's suggestion below, ran the following command after logging into dev server.

(ds_env) user@devvm1049:~$ jupyter notebook --no-mathjax --no-browser --ip 0.0.0.0 --port 8890
[I 23:49:56.032 NotebookApp] Serving notebooks from local directory: /home/user
[I 23:49:56.032 NotebookApp] The Jupyter Notebook is running at:
[I 23:49:56.032 NotebookApp] http://devvm.cdw.com:8890/
[I 23:49:56.032 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).

Copied the above link to both chrome and Safari but it didn't open anything.

I have already done the above suggestions in this post. The only thing that has worked until now is doing Port tunneling but that is 3 steps everytime one has to open the jupyter on remote server.

Is this can be some port blocking issue? I tried pinging the remote server on laptop and it didn't give me any ping.

Baktaawar
  • 7,086
  • 24
  • 81
  • 149
  • 1
    I argue the ssh tunnel is the obvious safe choice. You can nevertheless use, e.g., nginx to route a port from your external adapter to the localhost, or define '0.0.0.0' as your notebook interface. – Acorbe Apr 13 '20 at 09:37
  • cud u expand on the "define 0.0.0.0' as ur notebook interface option in detail? Thanks – Baktaawar Apr 13 '20 at 09:38
  • I think it makes a safer choice to configure the ssh config file to ease up the establishment of the tunnel (i.e. that you have `ssh remoteip`) and you get the tunnel established in one hit. Besides you can use autossh to ensure the tunnel persistency. – Acorbe Apr 13 '20 at 09:41
  • do u know how we can do that in one hit? – Baktaawar Apr 13 '20 at 18:30

1 Answers1

2

If you specify the --ip option when starting the server you can allow remote connection without port forwarding.

jupyter notebook --no-mathjax --no-browser --ip 0.0.0.0 --port 8890
# The --no-mathjax improves loading over slow connections

This is not recommended, though. See running a public jupyter notebook server. If you do this, I strongly recommend that you set a password, as described in that link.

Alex
  • 6,610
  • 3
  • 20
  • 38
  • Is the ip here my remoteip address or just 0.0.0.0 – Baktaawar Apr 13 '20 at 18:30
  • Using `0.0.0.0` will let you use the remote machine IP address to connect. So you can use `remoteip:port` in the browser. – Alex Apr 13 '20 at 19:00
  • Hi Pls check the edit. I ran the above command but it didnt seem to work. See the output. – Baktaawar Apr 14 '20 at 06:51
  • This could be caused by a firewall blocking incoming connections, you may need to be on vpn to access this server. You could try using the ip address from `hostname -I` as the remote IP – Alex Apr 14 '20 at 07:02
  • I am on vpn. Without vpn I can’t login to my dev server. I am not sure I am understand the second part. What do u mean” I can try using the IP address from host name” ? Thnx for your patience – Baktaawar Apr 15 '20 at 08:49
  • In your log it says that the server is running at `http://devvm.cdw.com:8890/`, instead of `devvm.cdw.com` you could try the server's ip address. You can use the command `hostname -I` to find the server IP – Alex Apr 15 '20 at 09:33
  • That is the server IP..I login to server using ssh devvm.cdw.com (I hv changed a bit due to privacy). Do u think it might be TCP port blocked? Or we mandatorily need port tunneling to connect jupyter to remote? – Baktaawar Apr 15 '20 at 18:47