Why I can't access remote Jupyter Notebook server?
Jupyter NotebookJupyter Notebook Problem Overview
I have started a Jupyter Notebook server on my centos6.5 server.And jupyter is running like
[I 17:40:59.649 NotebookApp] Serving notebooks from local directory: /root
[I 17:40:59.649 NotebookApp] 0 active kernels
[I 17:40:59.649 NotebookApp] The Jupyter Notebook is running at:https://[all ip addresses on your system]:8045/
[I 17:40:59.649 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
When I want to access Jupyter remotely in the same local area network, say open http://192.168.1.111:8045/
, I can't open a Jupyter page at all. By the way, I can access remote centos server successfully.
What's the possible reason?
Jupyter Notebook Solutions
Solution 1 - Jupyter Notebook
Have you configured the jupyter_notebook_config.py file to allow external connections?
By default, Jupyter Notebook only accepts connections from localhost (eg, from the same computer that its running on). By modifying the NotebookApp.allow_origin option from the default ' ' to '*', you allow Jupyter to be accessed externally.
c.NotebookApp.allow_origin = '*' #allow all origins
You'll also need to change the IPs that the notebook will listen on:
c.NotebookApp.ip = '0.0.0.0' # listen on all IPs
Also see the details in a subsequent answer in this thread.
Solution 2 - Jupyter Notebook
I managed to get the access my local server by ip using the command shown below:
jupyter notebook --ip xx.xx.xx.xx --port 8888
replace the xx.xx.xx.xx
by your local ip of the jupyter server.
Solution 3 - Jupyter Notebook
James023 already stated the correct answer. Just formatting it
if you have not configured jupyter_notebook_config.py file already
Step1: generate the file by typing this line in console
jupyter notebook --generate-config
Step2: edit the values
gedit /home/koushik/.jupyter/jupyter_notebook_config.py
( add the following two line anywhere because the default values are commented anyway)
c.NotebookApp.allow_origin = '*'
#allow all origins
c.NotebookApp.ip = '0.0.0.0'
# listen on all IPs
Step3: once you closed the gedit, in case your port is blocked
sudo ufw allow 8888
# enable your tcp:8888 port, which is ur default jupyter port
Step4: set a password
jupyter notebook password
# it will prompt for password
Step5: start jupyter
jupyter notebook
and connect like http://xxx.xxx.xxx.xxx:8888/login?
Solution 4 - Jupyter Notebook
In RedHat 7, we need to allow the specific port before running the Jupiter command. Say the port is 8080
.
iptables -I INPUT 1 -p tcp --dport 8080 -j ACCEPT
Then we can run it normally. For instance, using:
jupyter notebook --ip 0.0.0.0 --no-browser --port=8080 --allow-root
or whatever you like.
Solution 5 - Jupyter Notebook
Alternatively you can just create a tunnel to the server:
ssh -i <your_key> <user@server-instance> -L 8888:127.0.0.1:8888
Then just open 127.0.0.1:8888
in your browser.
You also omit the -i <your_key>
if you don't have an identity_file.
Solution 6 - Jupyter Notebook
From your command line, we can see your jupyter server is running normally.The reason you can't access your remote jupyter server is that your remote centos6.5 server's firewall rules block the incoming request from your local browser,i.e. block your tcp:8045 port.
sudo ufw allow 80 # enable http server
sudo ufw allow 443 # enable https server
sudo ufw allow 8045 # enable your tcp:8045 port
then try to access your jupyter again.
Maybe you also need to uncomment and edit that place in your jupyter_notebook_config.py
file:
c.NotebookApp.allow_remote_access = True
and even shut down your VPN if you have one.
Solution 7 - Jupyter Notebook
jupyter notebook --ip 0.0.0.0 --port 8888
will work.
Solution 8 - Jupyter Notebook
The other reason can be a firewall. We had same issue even with
jupyter notebook --ip xx.xx.xx.xxx --port xxxx.
Then it turns out to be a firewall on our new centOS7.
Solution 9 - Jupyter Notebook
To begin with, if not available, create a config file first
jupyter notebook --generate-config
Then head over to the file and edit it
cd ~/.jupyter
Uncomment the three lines or delete all and add the three lines
c.NotebookApp.allow_origin = '*' #allow all origins
c.NotebookApp.ip = '0.0.0.0' # listen on all IPs
c.NotebookApp.allow_remote_access = True
Try to connect with remote IP. (If you are using AWS EC2, you'll need to whitelist your ip and enable inbound connections for your client pc or all IP address over the port 8888)
If you still can't connect, you can try
jupyter notebook --ip 0.0.0.0 --port 8888
Solution 10 - Jupyter Notebook
I'm using Anaconda3 on Windows 10. When you install it rembember to flag "add to Enviroment Variables".
Prerequisite: A notebook configuration file
Check to see if you have a notebook configuration file,
jupyter_notebook_config.py
. The default location for this file
is your Jupyter folder located in your home directory:
- Windows:
C:\\Users\\USERNAME\\.jupyter\\jupyter_notebook_config.py
- OS X:
/Users/USERNAME/.jupyter/jupyter_notebook_config.py
- Linux:
/home/USERNAME/.jupyter/jupyter_notebook_config.py
If you don't already have a Jupyter folder, or if your Jupyter folder doesn't contain a notebook configuration file, run the following command:
$ jupyter notebook --generate-config
This command will create the Jupyter folder if necessary, and create notebook
configuration file, jupyter_notebook_config.py
, in this folder.
By default, Jupyter Notebook only accepts connections from localhost.
Edit the jupyter_notebook_config.py
file as following to accept all incoming connections:
c.NotebookApp.allow_origin = '*' #allow all origins
You'll also need to change the IPs that the notebook will listen on:
c.NotebookApp.ip = '0.0.0.0' # listen on all IPs
Solution 11 - Jupyter Notebook
if you are using Conda environment, you should set up config file again. And file location will be something like this. I did not setup config file after I created env in Conda and that was my connection problem.
C:\Users\syurt\AppData\Local\Continuum\anaconda3\envs\myenv\share\jupyter\jupyter_notebook_config.py
Solution 12 - Jupyter Notebook
If you are still having trouble and you are running something like EC2 AWS instance, it may just be a case of opening the port through the AWS console.
Solution 13 - Jupyter Notebook
edit the following on jupyter_notebook_config file
enter actual computer IP address
c.NotebookApp.ip = '192.168.x.x'
c.NotebookApp.allow_origin = '*'
on the client side launch jupyter notebook with login password
jupyter notebook password
after setting password login on browser and then type the remote server ip address followed by the port. example 192.168.1.56:8889
Solution 14 - Jupyter Notebook
Try doing the below step:
The following command fixes the read/write
sudo chmod -R a+rw /home/ubuntu/certs/mycert.pem
Solution 15 - Jupyter Notebook
I faced a similar issue, and I solved that after doing the following:
- check your jupyter configuration file: this is described here in details; https://testnb.readthedocs.io/en/stable/examples/Notebook/Configuring%20the%20Notebook%20and%20Server.html
-- you will simply need from the link above to learn how to make jupyter server listens to your local machin IP -- you will need to know your local machin IP (i use "ifconfig -a" on ubuntu to find that out) - please check for centos6
after you finish setting your configuration, you can run jupyter notebook at your local IP: jupyter notebook --ip=* --no-browser
please replace * with your IP address for example: jupyter notebook --ip=192.168.x.x --no-browser
you can now access your jupyter server from any device connected to the router using this ip:port (the port is usually 8888, so for my case for instance I used "192.168.x.x:8888" to access my server from other devices)
now if you want to access this server from public IP, you will have to:
- find your public IP (simply type on google what is my IP)
- use this IP address instead of your local IP to access the server from any device not connected to the same router kindly note: if your linux server runs on Virtual machine, you will need to set your router to allow accessing your VB from public IPs, settings depends on the router type. otherwise, you should be able to access the server using the public IP and the port set for it from any device not connected to your router, or using your local IP and the port set from any device connected to the same router!
Solution 16 - Jupyter Notebook
setting up a nohup jupyter notebook on a remote linux server using port 8888 as follows:
nohup jupyter notebook --no-browser --port 8888 &
will not work through multiple firewalls if using WSL2 (Debian/OpenSUSE or Ubuntu on Windows). The firewall will block the service at the jump to your remote server reporting a bind error on port 8888 when using:
ssh -N -L 8888:localhost:8888 remote-server-alias
I'm assuming a remote-server-alias is something that I have defined in my .ssh/config file using JumpProxy.
If you change port 8888 to 8889 you will see that jupyter can be loaded on all platforms including Windows 10. This is not an obvious gotcha and had me stumped for a whole day. Also needless to say, you must have an apache2 server up and running on the Windows machine.
So the magic is to always use:
ssh -N -L 8889:localhost:8888 remote-server-alias
Solution 17 - Jupyter Notebook
Is that your private IP address? If so you'll need to use your public one. Go to ipchicken to find out what it is. I know you are in the same LAN, but try this to see if it resolves any issues.
Solution 18 - Jupyter Notebook
I got the same problem but none of workarounds above work for me. But if I setup a docker version jupyter notebook, with the same configuration, it works out for me.
For my stituation, it might be iptables rule issues. Sometimes you may just using ufw
to allow all route to your server. But mine just iptables -F
to clear all rule. Then check iptables -L -n
to see if its works.
Problem fixed.
Solution 19 - Jupyter Notebook
Anyone who is still stuck - follow the instructions on this page.
Basically:
-
Follow the steps as initially described by AWS.
-
Open SSH as normal.
-
source activate python3
-
Jupyter Notebook
-
Don't cut and paste anything. Instead open a new terminal window without closing the first one.
-
In the new window enter enter the SSH command as described in the above link.
-
Open a web browser and go to http://127.0.0.1:8157