Jupyter Notebook do not open after connecting to an EC2 instance

I managed to connect to an EC2 instance using bash console (from mac)

After typing “jupyter notebook” a message informs me the notebook is running at…

I am then requested to copy and paste a link to my browser.

After doing so, I am told the browser cannot connect.

I would appreciate if someone could shed some light on this, thanks.

I just set one up right now using my usual approach and it worked.

My guess based on what you posted is that you have installed and have the notebook running; however, you need to connect your local port to the remote port. This is done through an SSH tunnel. You leave the current window running the notebook open and open another terminal window and connect via another SSH connection to the remote connection. You specify the ports to connect via the tunnel at that point.

You should be able to adjust your security group settings by adding a Custom inbound TCP rule like step #3 here (if you didn’t already) and then pickup back up with step #11 here and connect.

There is a slightly different take here where you specify the port at the time you start the notebook server. I actually follow that approach more closely and add in the no-browser option, and so my command to start the notebook server is jupyter notebook --no-browser --port 8756. (Note that I still only have 8888 as the inbound rule on the remote EC2 machine. Nothing involving 8756 in the rules.) My tunnel command is also more like here because I use Ubuntu and not the Amazon Linux and the N and f flags don’t seem necessary. This page discusses the SSH tunnel command more.

@fomightez

Many thanks for your time and detailed answer, I appreciate it.

I follow your indication and everything goes well until I complete step 11.

Once the jupyter notebooks are up and running and I get the URL with token displayed on bash (as on the post), I am unable to paste the next line code on my bash(it accepts no more text)

  • I try entering a new command by right clicking on the bash (mac), so I can run and enter the new command in the shell.

    ssh -NfL 9999:localhost:8888 ec2

  • The result is a new bash opens up and I am informed and I am informed I am logged out, it ends with [Process Completed]

I found (finally!) how to successfully connect from my bash to EC2 and then open Jupyter Notebooks.

This tutorial explains it well.

However, I am suprised once I on Jupyter Notebooks, I can only see a folder named src . I cannot navigate through my computer and find the notebooks I wish to run.

Does it mean I have to upload them prior running them?

Many thanks for your support.

Yes, the window running the notebook server won’t accept more text because it is running the server. That is why I said, “You leave the current window running the notebook open and open another terminal window” in my response.

Opening another, new terminal window while leaving the other untouched is important.

Glad that other tutorial helped clarify things for you. I’ll make a note of it myself as another useful resource.

Next, about your comment that you cannot navigate through your own computer when you are connected to the notebook server in your browser:

You are connected remotely to an Amazon machine and that is the system the notebooks are running on and the system to which the notebook server has access to by default. It won’t see anything on the drive of your local system by default. You can get your notebooks onto the remote machine a number of ways. One is to use the Jupyter notebook dashboard interface (in the classic notebok interface) and upload via your browser. This process is much easier these days if you are using JupyterLab interface instead because it lets you drag-and-drop from your local computer. Alternatively, you can use SCP at the command line (note this would involve opening yet a third terminal window and using SSH first to connect to your machine) or use an SFTP client. Both of those options are discussed here. (You may be able to find more recent guides to using those approaches with EC2.) Likewise, anything you generate on the remote machine, you need to download to your local system as well.

1 Like

@fomightez

Many thanks for your time and valuable explanations. I really appreciate.

Thanks to your responses, not only have I learnt a lot, but also I have learnt about resources I did not even know they existed!

Again, thank you very much @fomightez

Sincerely,

Josep Maria

1 Like