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?
This question is related to
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.
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.
Try doing below step:
Following command fixes the read/write
sudo chmod -R a+rw /home/ubuntu/certs/mycert.pem
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
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:
C:\\Users\\USERNAME\\.jupyter\\jupyter_notebook_config.py
/Users/USERNAME/.jupyter/jupyter_notebook_config.py
/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
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.
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.
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?
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.
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.
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.
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.
I faced a similar issue, and I solved that after doing the following:
-- 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:
jupyter notebook --ip 0.0.0.0 --port 8888
will work.
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
Anyone who is still stuck - follow the instructions on this page.
Basically:
Follow the steps as initially described by AWS.
source activate python3
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
Source: Stackoverflow.com