Peng He
Peng He

Reputation: 2213

Why I can't access remote Jupyter Notebook server?

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?

Upvotes: 162

Views: 285699

Answers (23)

Carson
Carson

Reputation: 1

ssh -L 8889:localhost:8888 192.168.xx.xx

just replace xx with local server ip. Open browser to localhost:8889 you might need to copy the key from the terminal.

Upvotes: 0

lam vu Nguyen
lam vu Nguyen

Reputation: 641

for example your computer's name is FEX-ple, your jupyter need run like

Use Control-C to stop this server and shut down all kernels (twice to

To access the server, open this file in a browser:
    file:///home/*******/.local/share/jupyter/runtime/jpserver-543245-open.html
Or copy and paste one of these URLs:
    http://FEX-ple:8888/tree?token=3445210404556345040gfhnsvsacasc404a8539cca455517
    http://127.0.0.1:8888/tree?token=3445210404556345040gfhnsvsacasc404a8539cca455517

with jupyter notebook --ip 0.0.0.0

then you access from ur browser with http://192.168.1.111:8888/tree?token=3445210404556345040gfhnsvsacasc404a8539cca455517

there should be no error

Upvotes: 0

Punit Pandey
Punit Pandey

Reputation: 405

This command worked for me -

jupyter lab --ip 0.0.0.0 --port 8888

Upvotes: 0

Jon
Jon

Reputation: 11

Just use:

jupyter lab --ip=0.0.0.0 --no-browser --allow-root &

Upvotes: 0

James023
James023

Reputation: 2256

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

Make sure that you uncomment these settings (remove the # at the beginning) after making any modifications. If you don't, they'll be interpreted as comments, and they won't change the behavior of the Jupyter notebook client.

Also see the details in a subsequent answer in this thread.

Documentation on the Jupyter Notebook config file.

Upvotes: 224

Pranjal Verma
Pranjal Verma

Reputation: 36

Try doing the below step:

The following command fixes the read/write

sudo chmod -R a+rw /home/ubuntu/certs/mycert.pem

Upvotes: 0

Eamonn Kenny
Eamonn Kenny

Reputation: 2062

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

Upvotes: 0

Charith Jayasanka
Charith Jayasanka

Reputation: 4812

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

Upvotes: 9

SmallChess
SmallChess

Reputation: 8126

jupyter notebook --ip 0.0.0.0 --port 8888 will work.

Upvotes: 12

Waly
Waly

Reputation: 326

I faced a similar issue, and I solved that after doing the following:

  1. 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:

  1. find your public IP (simply type on google what is my IP)
  2. 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!

Upvotes: 0

chris mahn
chris mahn

Reputation: 117

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

Upvotes: 0

Diya Li
Diya Li

Reputation: 1088

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.

Upvotes: -1

madx
madx

Reputation: 7203

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

Upvotes: 2

Hu Xixi
Hu Xixi

Reputation: 2157

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.

Upvotes: 12

Isopycnal Oscillation
Isopycnal Oscillation

Reputation: 3384

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.

see this answer

Upvotes: 0

Anyone who is still stuck - follow the instructions on this page.

Basically:

  1. Follow the steps as initially described by AWS.

    1. Open SSH as normal.
    2. source activate python3
    3. Jupyter Notebook
  2. Don't cut and paste anything. Instead open a new terminal window without closing the first one.

  3. In the new window enter enter the SSH command as described in the above link.

  4. Open a web browser and go to http://127.0.0.1:8157

Upvotes: -3

scyrt
scyrt

Reputation: 346

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

Upvotes: 0

Vikas Gupta
Vikas Gupta

Reputation: 1343

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.

Upvotes: 31

Jordan
Jordan

Reputation: 1645

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.

Upvotes: 14

Koushik Paul
Koushik Paul

Reputation: 1034

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?

Upvotes: 72

Teo Kok Keong
Teo Kok Keong

Reputation: 1406

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.

Upvotes: 129

Dhanas chenniappan
Dhanas chenniappan

Reputation: 176

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.

Upvotes: 4

Lucas Buhl-Nielsen
Lucas Buhl-Nielsen

Reputation: 119

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.

Upvotes: -1

Related Questions