3

I have already set up an EC2 instance on AWS (ubuntu, eu-central-1b). Port 8888 (custom tcp rule), https 443 and ssh 22 is open on AWS (anywhere). I'm aware of the chmod 400 key.pem and jupyter_notebook_config.py topics. It is also sucessfully set up Anaconda3-5x and also Jupyter on the EC2 instance. BUT: I cannot access the Jupyter Server on my browser (Firefox and Safari). When launching jupyter notebook after logging in to the EC2 instance, i get the PermissionError: [Errno 13] Permission denied error message. In the browser, I simply get a the connection has timed out error message.

I followed pretty much every tutorial there is such as:

https://chrisalbon.com/aws/basics/run_project_jupyter_on_amazon_ec2/ or https://github.com/mGalarnyk/Installations_Mac_Ubuntu_Windows/tree/master/AWS

I tried it a couple of times now, terminated the EC2 instance and set up the whole thing again. But still, I cannot connect to the Jupyter Server via the browser.

The exact error message looks like this the moment I try to connect / enter the URL in the browser:

(base) ubuntu@ip-172-31-34-13:~$ jupyter notebook [I 15:44:20.930 NotebookApp] JupyterLab extension loaded from /home/ubuntu/anaconda3/lib/python3.7/site-packages/jupyterlab
[I 15:44:20.930 NotebookApp] JupyterLab application directory is /home/ubuntu/anaconda3/share/jupyter/lab
[I 15:44:20.934 NotebookApp] Serving notebooks from local directory: /home/ubuntu
[I 15:44:20.934 NotebookApp] The Jupyter Notebook is running at:
[I 15:44:20.934 NotebookApp] https://(ip-172-31-34-13 or 127.0.0.1):8888/
[I 15:44:20.934 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
Exception in callback BaseAsyncIOLoop._handle_events(6, 1)
handle: <Handle BaseAsyncIOLoop._handle_events(6, 1)>
Traceback (most recent call last):
  File "/home/ubuntu/anaconda3/lib/python3.7/asyncio/events.py", line 88, in _run
    self._context.run(self._callback, *self._args)
  File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/tornado/platform/asyncio.py", line 122, in _handle_events
    handler_func(fileobj, events)
  File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/tornado/s**tack_context.py", line 300, in null_wrapper
    return fn(*args, **kwargs)
  File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/tornado/netutil.py", line 262, in accept_handler
    callback(connection, address)
  File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/tornado/tcpserver.py", line 263, in _handle_connection
    do_handshake_on_connect=False)
  File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/tornado/netutil.py", line 565, in ssl_wrap_socket
    context = ssl_options_to_context(ssl_options)
  File "/home/ubuntu/anaconda3/lib/python3.7/site-packages/tornado/netutil.py", line 540, in ssl_options_to_context
    context.load_cert_chain(ssl_options['certfile'], ssl_options.get('keyfile', None))**

There's also no difference when I use the 'https://(AWS Public DNS):8888' or the 'https://(AWS IPv4 Public IP):8888'

I tried even a different Port (8889) and stuff like this.

And as an info what my notebook_config looks like:

c = get_config()

c.IPKernelApp.pylab = 'inline'
c.NotebookApp.certfile = u'/home/ubuntu/certs/mycert.pem'
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.password = u'sha1:xxxxx'
c.NotebookApp.port = 8888

Everythings's basically set up like they showed in the tutorials. I tried it even like they showed officialy on AWS: https://docs.aws.amazon.com/dlami/latest/devguide/setup-jupyter-config.html

cz.official
  • 41
  • 1
  • 5
  • To clarify, after running `$ jupyter notebook`, the notebook successfully starts (showing the four outputs with `[I 15:44:20.934 NotebookApp]`), and then the error appears in the terminal once you try to connect from your local browser? – Nick Walsh Apr 26 '19 at 17:58
  • This is correct. I can start jupyter in the terminal (without having the permission denied error) but once I actually want to connect from my local browser, the error message(s) appear in the terminal. – cz.official Apr 26 '19 at 18:51
  • Possible duplicate of [Trouble with Jupyter certifications](https://stackoverflow.com/questions/52673879/trouble-with-jupyter-certifications) – recnac Apr 27 '19 at 04:11

3 Answers3

7

It might be a permissions error with the cert.pem file. Assuming the directory is correct for mycert.pem as listed in your notebook_config file, from the terminal that's SSH'd into the EC2 instance, you can use the following command:

sudo chown $USER:$USER /home/ubuntu/certs/mycert.pem

Possible duplicate of this question: Trouble with Jupyter certifications

Nick Walsh
  • 1,807
  • 5
  • 16
  • Wow, that was it. Thank you! Would you mind telling me what sudo chown does? And do I have to type it in every time I log into my EC2 instance? – cz.official Apr 26 '19 at 18:58
  • No problem! `chown` changes the system owner of the file. Here, by changing the owner of the file to the current user, it should enable persistent access privileges, as this is saved on the server. – Nick Walsh Apr 26 '19 at 21:14
0

Make sure not to use private ip but rather public ip, I still got above error after handling permission error on certificate by sudo chown $USER:$USER /home/ubuntu/certs/mycert.pem

Also, if you get SSL error make sure to use https:\\ before ip:<port number>

Also make sure to check inbound rules of security group to make sure you are trying right ports to access.

Hari_pb
  • 7,088
  • 3
  • 45
  • 53
0

For me, the problem was because of read permission.

Following command fixes the read/write for all groups.

sudo chmod -R a+rw /home/ubuntu/certs/mycert.pem
Mehdi
  • 999
  • 13
  • 11