9

I've been having trouble connecting to a Jupyter notebook instance on AWS. This is a little out of my wheelhouse, so any help would be appreciated!

ubuntu@ip-172-31-20-132:~$ export XDG_RUNTIME_DIR=""
ubuntu@ip-172-31-20-132:~$ jupyter notebook
[I 22:04:19.553 NotebookApp] JupyterLab extension loaded from /home/ubuntu/anaconda3/lib/python3.7/site-packages/jupyterlab
[I 22:04:19.553 NotebookApp] JupyterLab application directory is /home/ubuntu/anaconda3/share/jupyter/lab
[I 22:04:19.557 NotebookApp] Serving notebooks from local directory: /home/ubuntu
[I 22:04:19.557 NotebookApp] The Jupyter Notebook is running at:
[I 22:04:19.557 NotebookApp] https://(ip-172-31-20-132 or 127.0.0.1):8888/?token=fdef54981e6ae03e4f7a59276436982ff7ed1f28c7714901
[I 22:04:19.557 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 22:04:19.558 NotebookApp] 

    Copy/paste this URL into your browser when you connect for the first time,
    to login with a token:
        https://(ip-172-31-20-132 or 127.0.0.1):8888/?token=fdef54981e6ae03e4f7a59276436982ff7ed1f28c7714901
Exception in callback BaseAsyncIOLoop._handle_events(7, 1)
handle: <Handle BaseAsyncIOLoop._handle_events(7, 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/stack_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))
PermissionError: [Errno 13] Permission denied
DeepThoughts
  • 91
  • 1
  • 3
  • 1
    did you manage to find a solution for this? – Turo Oct 25 '18 at 07:10
  • Also having the same issue, hoping someone finds a workaround. Have found this github issue but doesn't seem to fix anything for me https://github.com/jupyter/notebook/issues/507 – scrollex Nov 26 '18 at 00:19

2 Answers2

9

So I had this issue and it was due to a permission issue with your cert file as referenced in your jupyter config file. In jupyter_notebook_config.py I referenced mycert.pem. I changed the ownership of mycert.pem to my standard user account.

sudo chown user:user ~/certs/mycert.pem

This cleared the problem.

GrandmasLove
  • 465
  • 1
  • 4
  • 14
  • 4
    On an ec2 ubuntu instance i changed the command to `sudo chown $USER:$USER ~/certs/mycert.pem` and it worked as well. Thank you for the help – Geochem B Dec 18 '18 at 15:06
  • 2
    I know that upvote is enough, but I really must say... Thank you! @GeochemB – curious95 Mar 16 '19 at 11:56
  • Is it known why would anyone all of a sudden set a custom ownership of a certificate's file? Why would that even require it? For example, in case of Nginx running as `nginx:nginx`, the cert has `root:root` and is generated and handled via independent `certbot` or `Let's Encrypt` with no permission issues! I am sorry, but this all does not make much of sense... – Artfaith Apr 16 '23 at 05:21
0

Check for the below few things to make sure you handle permission error while using jupyter notebook on AWS EC2 machine:-

1: Make sure not to use private ip but rather public ip,

2: Error after handling permission error on certificate by

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

3: Handle SSL error, make sure to use https:// before ip:<port number>

4: 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