3

I'm trying to open Jupyter notebook in a browser. Jupyter seems to have connected just fine:

[I 20:38:02.663 NotebookApp] Serving notebooks from local directory: /home/user/.jupyter
[I 20:38:02.663 NotebookApp] Jupyter Notebook 6.2.0 is running at:
[I 20:38:02.663 NotebookApp] http://nameofVM:8888/

But when I plug in the URL given (http://nameofVM:8888/) the page doesn't load, with an error message just like when you try to visit a page where the site doesn't exist.

I've already tried all the steps from the solutions in this post. I've also read through and tried troubleshooting with the documentation. I'm not sure how to fix this, and if maybe there's a Linux specific solution to this. Does anyone have any suggestions? I'd be grateful.

Notes:

  • When I checked a list of all my kernels, I have one:

    python3 /home/user/.local/share/jupyter/kernels/python3

  • I am using a Linux VM running Ubuntu 16.04.7

4
  • What is the error message exactly? Are you sure nameofVM is resolved? Have you tried with IP? Commented Oct 21, 2021 at 1:22
  • @tomasz There's no error message in my CLI, just in my browser: I get the default blank page that says the site cannot be reached, the same as if I try to visit any website where the URL has a typo. What do you mean by "nameofVM" is resolved? it's just a placeholder for the actual name of my virtual machine. It's the link that Jupyter says it's running the notebook on. And yes, I've tried myipaddress:8888 with my actual ip address, and ran into the same problem. Commented Oct 21, 2021 at 1:39
  • That's mysterious. Are you using a browser on the host or in the vm? Commented Oct 21, 2021 at 1:46
  • @tomasz I just used my normal browsers on my computer (so local, I guess, over my home wifi). Should I be doing it through the VM? I'm new to VMs so I'm not entirely sure how I could access an in-VM browser Commented Oct 21, 2021 at 1:59

2 Answers 2

2

I think this may be due to a default configuration made in Jupyter for security.

The problem

To to be clear about your situation: You have a host machine (unknown OS) and virtual machine (Ubuntu). Despite the face they are running on the same box, they logically behave as if they are two completely different machines. So as far as networking between the two goes, you need to imagine these are two different machines which happen to be on the same network.

By default Jupyter listens only on IP address 127.0.0.1 (mentioned here). This is known as "localhost" or "loopback" and it is only accessable from the same machine as Jupyter is running on. It is NOT accessible from any other machine. So if Jupyter is not configured to listen on another address then your host machine will not be able to connect.

Allowing your host machine to connect

To let your host machine you need to configure Jupyter as if it is running a public server. That's because the Virtual machine will act as a server and your host machine will act as a client.

This should be simple enough. Run jupyter like this:

jupyter notebook --ip=* --no-browser

This tells Jupyter to listen on all IP addresses (*) and also tells it not to try and launch a browser on your VM.

You should then be able to connect to it with your virtual machine's IP address: From your comments that's http://10.1.1.4:8888.

Security - DO NOT IGNORE!

Jupyter allows someone connected to any arbitrary code they like.

You've not listed anything about your VM's hypervisor or your VM's configuration. Depending on the way the networking has been setup, your VM may be network connected in a couple of different ways:

  • It could be configured with a virtual network emulated by the host machine. In this case the VM's internet access will come through a NAT. By default this is secure. Other physical machines on your network will not be able to access your Jupyter.

  • It could be configured with host networking, where the VM has its own IP address on the host's LAN/WAN. This is dangerous! With this type of networking Jupyter will be accessible by default to anyone else on your LAN/WAN so be very careful to secure it correctly.

Please check carefully which you are using.

0

You need to figure out the ip of your vm that runs Jupyter. My guess is that your secret nameofVM sounds "localhost", which means "this machine". But since you are browsing from your vm's host "localhost" on the host means the host, not the vm. To find out the ip, run on the vm:

ip a

And you should get a listing of your network interfaces. The one with 127.0.0.1 is also localhost, meaning "this machine". So you want the other ip. If you run ip a on your host, you will find a similar ip as on the vm, and that's how they communicate. I'm assuming here your host is a Linux also. And if you want to reach that service (Jupyter I mean) by name, then you need a resolver, which is another story, I gather.

And to clarify you terminology: vm is an instance that runs within or under the host. So saying you're using Linux VM running Ubuntu is wrong I guess, since it states you are running one virtual machine (under some unknown host) and one more inside it, which is Ubuntu.

As for the wi-fi detail in your comment, it is completely unrelated, because the host connects to the vm within it through a virtual network it creates, so you disconnect all the wi-fi's you use and it will still be fine.

You can also try to use a browser within the vm, but for this you need a vm with the graphical interface (as opposed the text interface).

9
  • Thanks for your detailed answer! I tried running ip a and used the one that wasn't 127.0.0.1, so I put http://10.1.1.4:8888 into my browser, but got the same issue again. I also tried the public ip address of my VM and it didn't work. Am I misunderstanding something? Commented Oct 21, 2021 at 2:29
  • @samster It should be enough to just try the ip of your vm running Jupyter, so probably you misunderstood this. Otherwise, I think what's going on is the binding address. As you saw in the listing from ip a, there are many interfaces, and Jupyter is - I guess - binding to just localhost or 127.0.0.1 (it's the same from the point of view of the vm). What you should do then is to make it bind to the interface you can reach from your host. So make sure it does bind to where you try to reach it. The documentation mentions the config parameter c.NotebookApp.ip. Consult the documentation. Commented Oct 21, 2021 at 2:38
  • @samster I just checked the link from your question. It covers even more than I did, so make sure that is correct. If it doesn't help, it might be many things and you'll have to troubleshoot. For a quick fix, try to use a browser in the vm. Maybe it's that simple. Commented Oct 21, 2021 at 2:42
  • "using Linux VM running Ubuntu" is perfectly correct here. "since it states you are running one virtual machine (under some unknown host) and one more inside it, which is Ubuntu." no it doesn't.... a machine runs an OS. A virtual machine runs an OS. So the OPs wording does not infer any kind of nested VM. It merely states which OS the VM is running. Commented Oct 21, 2021 at 7:25
  • @PhilipCouling Does it say then the host is Linux? I'm not a native speaker and I'm happy at having this little linguistic problem here. Commented Oct 21, 2021 at 11:23

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.