Last Updated: June 24, 2019
· cheglastgnat

Remote Access to IPython Notebooks via SSH

Scenario: On your local computer, you want to open and manipulate an IPython notebook running on a remote computer. We will do this by opening an SSH tunnel. This tunnel will forward the port used by the remotely running IPython instance to a port on the local machine, where it can be accessed in a browser just like a locally running IPython instance.

On the remote machine, start the IPython notebooks server:

remote_user@remote_host$ ipython notebook --no-browser --port=8889

Usually IPython opens a browser to display the available notebooks, but we do not need that so we use the option --no-browser. We also change the port to 8889, for no other reason than to show how this is done.

On the local machine, start an SSH tunnel:

local_user@local_host$ ssh -N -f -L localhost:8888:localhost:8889 remote_user@remote_host

The first option -N tells SSH that no remote commands will be executed, and is useful for port forwarding. The second option -f has the effect that SSH will go to background, so the local tunnel-enabling terminal remains usable. The last option -L lists the port forwarding configuration (remote port 8889 to local port 8888).

Now open your browser on the local machine and type in the address bar


which displays your remotely running IPython notebook server.

To close the SSH tunnel on the local machine, look for the process and kill it manually:

local_user@local_host$ ps aux | grep localhost:8889
local_user 18418  0.0  0.0  41488   684 ?        Ss   17:27   0:00 ssh -N -f -L localhost:8888:localhost:8889 remote_user@remote_host
local_user 18424  0.0  0.0  11572   932 pts/6    S+   17:27   0:00 grep localhost:8889

local_user@local_host$ kill -15 18418

Alternatively, you can start the tunnel without the -f option. The process will then remain in the foreground and can be killed with ctrl-c.

On the remote machine, kill the IPython server with ctrl-c ctrl-c.

74 Responses
Add your response


This does not work when I have to use SSH to get to the remote machine to start the IPython notebooks server, right?

over 1 year ago ·

That should work as well, yes. Is there a problem with the first step?

over 1 year ago ·

Oh, I am sorry. The first time I tried this, I couldn't start the second SSH tunnel on my local machine, and from the error I assumed that it's not possible. I thought if I have to open a "standard" SSH tunnel to start IPython notebooks server on the remote machine I would not be able to open a second one setting the port forwarding.
I was wrong, though, since it worked perfectly fine this time.

over 1 year ago ·

Ah, good to know it works! :)

By the way, you don't have to keep both ssh connections open. I usually use screen or tmux on the remote server to keep my remote session alive. This way, I only have to login once to start the IPython notebook server, then I can detach the session and logout.

over 1 year ago ·

I haven't heard of any of these before... but it seems we have screen on the server already! Thanks for the tip, I'll try that right away. :-)

over 1 year ago ·

Onn the browser I got "channel 2: open failed: connect failed: Connection refused" It works tunneling ssh -N -f -L localhost:8888: Juhuuuu!!!

over 1 year ago ·

Hi ilciavo, thanks for your comment! Perhaps there is a security setting on your machine which blocks that specific port of "localhost"?

over 1 year ago ·

I am getting the same error as ilviavo, but using the address doesn't work for me. I also get:
bind: Address already in use
channelsetupfwd_listener: cannot listen to port: 8888
Could not request local forwarding.

But searching for ps aux | grep localhost:8889 or ps aux | grep localhost:8888 doesn't show anything.

Any suggestions?

over 1 year ago ·

Hi Nic,
sounds like port 8888 might already be in use on your machine. If that's the case, it should show in the output of
"netstat -tulpn | grep 8888" (might need root)
You can try any other port above 1024 :)

over 1 year ago ·

Great tutorial! I want to add a tip for enabling display of remote figures (I got a DISPLAY error when the remote server executing my ipython notebook code didn't have anywhere to put Xwindows)

Although you can use XPRA to forward the entire browser window remotely, it's slow. Combining xpra for remote display of xwindows (e.g., matplotlib or mayavi figures), you can combine the advice from here (https://wiki.archlinux.org/index.php/Xpra)

remote@remote$ xpra start :100

remote@remote$ DISPLAY:=100 screen

remote@remote$ ipython notebook --no-browser --port=8889

local@local$ ssh -N -f -L localhost:8888:localhost:8889 remoteuser@remotehost

And you'll see figures opened on your remote machine pop up in xpra windows on your local machine

over 1 year ago ·

Hi phareaux,

thanks for the (pro)tip! Usually inline figures are good enough for me, but this sounds great.

over 1 year ago ·

Hi cheglastgnat,

I try to use inline figures as well, but unfortunately mayavi inlining in ipython notebook isn't (yet) well supported (screenshots, no interactivity). It doesn't seem to actually forward the interactive scenes (empty windows), but it doesn't give me errors.

over 1 year ago ·

If I need the ipython notebook process continues to run even if the ssh disconnect, simply remove the -f command? So I can access the process until new connection just reconnect ssh with the same port of the process?
I will make a parallel programming processing and machine learning, the training will last about 15 days and must monitor the process, would do via shell normally, but the idea of using the ipython notebook is extremely more satisfactory ...

over 1 year ago ·

As an amendment to my previous comment (about xpra), I think there's a simpler way to do X forwarding of a window outside of the ipython notebook environment. Also, the way I tried doing kept failing for awhile, so I got the below to work (also, there's a typo in the old DISPLAY=:Z string)

  1. create vnc server on remote host, which will allocate a new X display if necessary and tell you it as an integer: <outputfromvncserver> remote@remote$ vncserver
  2. either a. export the resulting display via remote@remote$ export DISPLAY=:<outputfromvncserver> and then start ipython notebook with command recommended by article (with same environment!) or 2b.
  3. start ipython notebook
    inside the notebook

    import os
    os.environ['DISPLAY'] = '<outputfromvncserver>'

  4. now you can use a vncviewer with something like
    local@local$ vncviewer remote@remote:<outputfromvncserver>

and you'll see a remote desktop appear, along with any mayavi figures (or other out-of-notebook X windows?) you might be using

over 1 year ago ·

Thanks so much

over 1 year ago ·

If you're on a secure network just pass -ip=* and you can connect it from all machines without SSH tunneling!

over 1 year ago ·

Nice tutorial.. Was precisely looking for this! :)

@phareaux: regarding X forwarding, is there a reason why X forwarding over ssh wouldn't work?

over 1 year ago ·

The kernel keeps disconnecting when I'm away from my seat. Sometimes I need the GPU running for hours to reach the end result; does anyone have solutions to this?

over 1 year ago ·

I'm trying to use this protocol, but when I try to create a new Python notebook in my browser the Jupyter notebook dies and no new notebook is created. No useful error is outputted either. Has anyone else encountered this problem?

over 1 year ago ·

I think that using same port on local and remote will be better for clarity, it is possible https://maketips.net/tip/148/forward-remote-port-to-local-using-ssh

over 1 year ago ·

This is an excellent tutorial. I have one question though: is it possible to run a python console side by side using the same kernel? I'm a fan of using Jupyter's qtconsole, but this requires me use XQuartz, which gives me a console with a UI that is quite sluggish.

over 1 year ago ·

Great tutorial. Thanks a lot!

over 1 year ago ·


over 1 year ago ·

worked with Jupyter Notebook following the exact instructions. many thanks

over 1 year ago ·


10 months ago ·

We also change the port to 8889, for no other reason than to show how this is done.Inform on https://www.hptechsupportnumbers.com/hp-customer-support/

8 months ago ·

This is a free service we are offering with no strings attached. We, however, ask that when you do contact us try to be as detailed as possible so that an accurate assessment can be made and the correct solution can be given. If you are facing any problem related to Apple Issues please visit:- https://www.appletechnicalsupportnumbers.com/

8 months ago ·

I understand that it is easy to use to explore data when messing around with graphs, however i come from web development and i feel like the work flow when using Jupyter is horrible. A quick list of drawbacks using Jupyter:

If you work in a team and want to use git, it is a mess.

You end up writing horrible code that is messy to read and keep track of in the notebook, even after splitting code across multiple notebooks.

https://appsync.biz/speed-test/ https://appsync.biz/scrabble-word-finder/ https://appsync.biz/solitaire/

8 months ago ·

It is very helpful tutorial....We offer HP technical Support Service for all HP devices, with the help of our experts who are highly knowledgeable and well versed in resolving such issues. We Provide Toll-free (+1-855-461-5433) and Live chat to connect with our Experts Team.Visit: http://www.hptechnicalsupport247.com/

7 months ago ·

Whenever you face technical glitches while using AOL Desktop Gold software. Don’t, worry and call on the AOL Desktop Gold customer support number. Yes, call on this toll-free number and talk to certified techies. Share your problem with these techies who will provide you the best possible solution to the problem.
For more information click on this link:-

5 months ago ·

Impressive information you used in this post. I will not hesitate to share with my friends. http://www.applesupport247.com//blog/how-to-fix-500-internal-server-error-on-mac/

4 months ago ·

Great article for Python developers...

4 months ago ·
4 months ago ·

you are going to right way with python.https://www.avastsupportnumber.us/

4 months ago ·

SAP Business One puts business users in charge, arming you with the critical, up-to-the-minute information you need to make smart business decisions.

4 months ago ·

WOW I appreciate your post, Please Keep posting with more information…

From https://www.onsiteassistances.com/magicjack-customer-service

4 months ago ·

I appreciate your post, Please Keep posting with more information…
From -https://www.thedevicesupport.org/spectrum-customer-support

3 months ago ·

It is a very helpful tutorial....We give Technical Support for Printers, Complaint, Warranty guarantee, Refund, Returns and Repairs, and other client administration issues. https://www.printershelp.info/

3 months ago ·

We provide technical support services for
Call 1-844-539-9831 for a free diagnosis.

IGuru Services is one of the leading global technical support providers to consumers worldwide. We provide most affordable and flexible support services for PCs, MACs, iOS devices and Peripherals. We are also one of the best technical support providers for Epson Printers tech support. We work 24x7, so no matter where you are and when you need help, we are just a phone call away. All of the services are mostly delivered remotely via highly secured and encrypted platform.
Call 1-844-539-9831 for a free diagnosis

3 months ago ·

Thanks for the information. To get the best tech help contact geek squad tech support team for help

3 months ago ·
3 months ago ·

We had extremely professional people in our support they are working 24×7 to help customers on each technical problems they are facing. Get PayPal support now.

2 months ago ·

Hewlett Packard manufactures high-end printers of all kinds for domestic as well as office use HP Support Assistant.

2 months ago ·

Its working Very Helpful Information, I like it Very Much.. Thanks for this post


2 months ago ·

I think this is one of the best blog for me because this is really helpful for me. Thanks for sharing this valuable information for free

2 months ago ·

nice post
very helpful article

about 2 months ago ·

Nice tutorial.. Was precisely looking for this! :)

about 2 months ago ·

Nice article Thanks Helpfull for me: https://www.filingbuzz.com/service/iec-registration

about 2 months ago ·

Hi, thanks for this wonderful post. It is really helpful. TomTom One XL is one of the devices offered by TomTom to the customers and it is very necessary that the users might need to perform update a tomtom One XL.

about 1 month ago ·

I got complete information about Remote Access to IPython Notebooks via SSH at https://www.epsonprintersupport.co/

about 1 month ago ·

Great work, thanks a lot for sharing this.

about 1 month ago ·

Whenever you face technical glitches while using AOL Desktop Gold. Don’t, worry and call on the AOL Desktop Gold support number. Call on this toll-free number and talk to certified techies. Share your problem with these techies who will provide you the best possible solution to the problem.
For more information click on this link:- https://getemailservices.com/install-aol-desktop-gold/

28 days ago ·

When you are going to travel then the most important thing you want is a proper airline with the best facility. Alaska Airlines is one of the best airline. You will be getting the feeling of a home. And by any condition, if a Customer is facing any difficulty then he or she can take the help of the Alaska Airlines Customer Service. Once you contact them you will be able to resolve the issues quickly.
If you want more information:- https://helpsupportservices.com/airlines/alaska-airlines-customer-service/

28 days ago ·

AVG Support helps the troubled customers who are having issues with there antivirus software. Also the experts working at the AVG Support Number are accessible 24/7 to rescue every user.

28 days ago ·

This line is very a gifted point of view, well spoken! Thanks!
We do provide the best services of the limo at an affordable price and on time pickup and drop off.
• Tacoma Limousine School Events
• Tacoma Limo Airport Service
You may book in limited time offer via contact our website:

28 days ago ·

So much info in so few words, Thanks learn a lot!

Seattle is a fascinating place you can ever come across. With Seattle, Limo Services tourists can visit various places and enjoy the experience that the city has to offer.
• Seattle Cruise Transportation
• Seattle Rental for Seattle Cruise Terminal
Visit: http://www.seattle-limoservice.com/seattle-cruise-transportation/

28 days ago ·

Brother Printer Support Number is usually an independent on-line service provider of remotely gain access to technical support intended for third party services and products. Connect with us to get help regarding any issues related to your Brother Printer.
Visit Our website:-https://www.brotherprintersupport.net/

7 days ago ·

Thanks for the information. To get the protection against viruses contact norton support team for help,

5 days ago ·

QuickBooks Customer Service is available round the clock to resolve accounting problems. Reach experts at QuickBooks Customer Service Number and get instant help.

5 days ago ·

Best guide through the process to remotely access ipython notebook via SSH
Thanks for Sharing
Read more: http://aptronnoida.in/best-python-training-in-noida.html

4 days ago ·

Not Able to Find Belkin.setup in Network list.Get all in one guide to Help You Setup,Configuration,Troubleshoot Belkin wifi range extender by visiting

3 days ago ·

Experience the best printer services with hp customer service 1-888-410-9071. hp is a brand name in the printer market for years and offers outstanding print services. hp printer service assists internet users to resolve their numerous queries & complaints with ease. hp printer users easily get the best possible solutions by dialing our service number.

We deliver hp printer services with the motto to gain customers trust & satisfaction by offering them quality services. We work in a 24x7 environment to assist our valued customers more conveniently.

Our other hp printer services include:-

hp customer support 1-888-410-9071
hp printer support 1-888-410-9071
hp support number 1-888-410-9071
hp customer service 1-888-410-9071
Visit our official website:- http://www.kontactforhelp.com/hp-printer-support/

1 day ago ·

The Information that i got is really reliable and admirable, HP Printer Support is her to help you in all aspects of technical help to your devices https://hpprinterstroubleshooting.com/

1 day ago ·