Reputation: 2459
I'm running Ubuntu 14.04 LTS on an AWS EC2 instance. I'm trying to connect to Jypter in Safari from my MacBookPro. I opened https port 443 and TCP 8888 in my security group.
ubuntu@ip-10-0-1-62:~$ netstat -a | grep 8888
tcp 0 0 localhost:8888 *:* LISTEN
tcp 0 0 localhost:8888 localhost:36190 TIME_WAIT
ubuntu@ip-10-0-1-62:~$ netstat -a | grep 443
unix 3 [ ] STREAM CONNECTED 12443
ubuntu@ip-10-0-1-62:~$
I can't connect to Jupyter from my Safari browser on my Mac. (I can connect to Tensorboard on port 6006).
ubuntu@ip-10-0-1-62:~$ jupyter notebook
[W 20:40:14.909 NotebookApp] Unrecognized JSON config file version, assuming version 1
[I 20:40:14.921 NotebookApp] Writing notebook server cookie secret to /run/user/1000/jupyter/notebook_cookie_secret
[I 20:40:15.224 NotebookApp] JupyterLab alpha preview extension loaded from /home/ubuntu/anaconda/lib/python2.7/site-packages/jupyterlab
[I 20:40:15.230 NotebookApp] Serving notebooks from local directory: /home/ubuntu
[I 20:40:15.230 NotebookApp] 0 active kernels
[I 20:40:15.230 NotebookApp] The Jupyter Notebook is running at: http://localhost:8888/?token=c08a71a48c6e159bdbdcc95837c4e2e053349382c681899b
[I 20:40:15.231 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 20:40:15.232 NotebookApp]
Copy/paste this URL into your browser when you connect for the first time,
to login with a token:
http://localhost:8888/?token=c08a71a48c6e159bdbdcc95837c4e2e053349382c681899b
$ telnet 52.8.16.250 8888
Trying 52.8.16.250...
telnet: connect to address 52.8.16.250: Connection refused
telnet: Unable to connect to remote host
$ telnet 52.8.16.250 6006
Trying 52.8.16.250...
telnet: connect to address 52.8.16.250: Connection refused
telnet: Unable to connect to remote host
$ telnet 52.8.16.250 8080
Trying 52.8.16.250...
telnet: connect to address 52.8.16.250: Connection refused
telnet: Unable to connect to remote host
$ telnet ec2-52-8-16-250.us-west-1.compute.amazonaws.com 8888
Trying 52.8.16.250...
telnet: connect to address 52.8.16.250: Connection refused
telnet: Unable to connect to remote host
$ telnet ec2-52-8-16-250.us-west-1.compute.amazonaws.com 20
Trying 52.8.16.250...
telnet: connect to address 52.8.16.250: Operation timed out
telnet: Unable to connect to remote host
Upvotes: 26
Views: 19718
Reputation: 81
I faced similar issue, I used anaconda to install jupyter.
Problem was notebook server was not listening on the public ec2 address, only localhost.
I resolved this issue using following command
jupyter notebook --ip=<public ipv4 DNS>
Here:
--ip=<Unicode> (NotebookApp.ip)
Default: 'localhost'
The IP address the notebook server will listen on.
Upvotes: 0
Reputation: 10184
Here is a full workflow end to end to run a Jupyter notebook or Jupyterlab on an Amazon AWS EC2 instance. (Expanding on @alexopoulos7's answer)
SSH
, port 22
, source 0.0.0.0/0
, outbound all traffic, all ports).pem
file).~/ec2.pem
. Set proper file permissions with chmod 400 ~/ec2.pem
.ssh -i ec2.pem ec2-user@< PUBLIC IPv4 ADDRESS OF YOUR INSTANCE >
. If the IP address is for example 18.1.10.199
then the command is ssh -i ec2.pem [email protected]
wget https://repo.anaconda.com/miniconda/Miniconda3-latest-Linux-x86_64.sh
, then bash Miniconda3-latest-Linux-x86_64.sh
. Confirm all default choices when prompted. Confirm with yes
, when asked if you wish the installer to initialize Miniconda.exit
and ssh again into your instance for changes to take effect.conda create -n myenv python=3.8
.conda activate myenv
.conda install jupyter notebook jupyterlab
jupyter lab --no-browser
ssh -i ec2.pem -NL 9999:localhost:8888 [email protected]
. The arguments: -i
sets the key file, -N
just forwards ports without executing a remote command and -L
sets the connection from your local port – in our example 9999
– to the remote host/port.8888
locally has the advantage that you simultaneously can use jupyter notebook locally and remote.localhost:9999
as URL and login with the token that you see in the remote shell when you start jupyter. You should be good to go... 👍PS: Don't forget to terminate your instance after you're done.
Upvotes: 3
Reputation: 1373
I was getting above error but tried command: jupyter notebook --ip=*
This worked for me.
Upvotes: 7
Reputation: 51
Make sure your AWS instance security group configured as below screenshot: aws instance inbound security group configured
If you are sure that AWS is configured correctly for permissions, check if your network is not blocking the outbound traffic. You could try to do port tunneling when SSHing into your instance by doing:
ssh -i -L 8888:127.0.0.1:8888
then you can access jupyter locally by going to localhost:8888 on your browser
Upvotes: 5
Reputation: 1781
Okay, found the issue:
Edit your jupyter configuration:
jupyter notebook --generate-config
vim /home/ubuntu/.jupyter/jupyter_notebook_config.py
Make sure that
c.NotebookApp.ip = '*'
Also make sure you opened the relevant security group in your EC2 server (for example port 8888)
Run Jupyter:
jupyter notebook
Now you can access it remotely with the right port
Upvotes: 23
Reputation: 912
For me ssh tunneling works great for such cases.
ssh -i /path/to/your/AWS/key/file -NL 8157:localhost:8888 user@host
where user and host depend on your ec2 instance.
After that you can browse to http://localhost:8157/
Upvotes: 16