Instantly share code, notes, and snippets.

What would you like to do?
Create an iPython HTML Notebook on Amazon's AWS Free Tier from scratch.


Roll your own iPython Notebook server with Amazon Web Services (EC2) using their Free Tier.

What are we using? What do you need?

  • An active AWS account. First time sign-ups are eligible for the free tier for a year
  • One Micro Tier EC2 Instance
  • With AWS we will use the stock Ubuntu Server AMI and customize it.
  • Anaconda for Python.
  • Coffee/Beer/Time


I had been looking for complete tutorials on setting up my own iPython Notebook on EC2 from scratch and I couldn't quite find what I was looking for. I hope someone finds this useful!

Why Anaconda over Enthought?

I've used the Enthought Free distribution on my own system for a while but it was missing some packages that I loved. For future uses I wanted a distribution that I didn't have to modify out of the box. I looked around and stumbled across Continuum's package. I liked where they were taking their products. Not to mention their free distribution had many, many awesome packages already included. Why not?


AWS Console and EC2 Instance Launch.

  • Head over to the AWS Console and log in.
  • We're going to Launch an Instance. If this is your first time at the Rodeo you won't have any instances listed.

Launch Instance

  • We're going to use the Classic Wizard for the Instance Creation

Classic Wizard

  • There are many OS's to choose from. All the eligble OS's eligible for the Free Tier are marked by big, bold stars. We're going to use Ubuntu Server 12.04.1 LTS.


  • The free tier is only eligible for the T1 Micro. I will use all defaults here.

Instance Type

  • Again in the Advanced Instaces options I leave all options at their default settings.

Advanced Instance Questions

  • You can create tags for machines. I haven't found the need to yet. Defaults!


  • The Wizard is going to ask you to create a public key (or use an existing one if this isn't your first time). Create and download that key and save it in a nifty (read: memorable) spot.

  • The Security Group step is a very important step. This step can only be configured when you launch the instance! Under the Create New Security Group.

Security Groups

  • You should have rules for SSH(22):, HTTPS(443):, and 8888: Where means access from ANY outside I.P. address. We will use port 8888 for our iPython Notebook server. Your rules should look like the right hand size of the photo below.


  • This is the last page of the Wizard! Review the options you set and if they look good the you're all set.

Instance Details Complete

SSH-ing into your Instance

  • I'm going to assume you're using the Terminal in Mac OS X (or something vaguely Unix-y).
  • Right-Click on the instance you just created from the Instances panel then click Connect

Connect with SSH Client

  • The Connect diaglog box will give you some code you can use to log in to your instance. In your terminal Navigate to where you saved your PEM key and run the command from there. WATCH OUT #1: If you haven't changed the permissions on your key then the server is going to reject the connection. CHMOD 400 (your PEM). WATCH OUT #2: Ubuntu wants you to login as ubuntu rather than root. Change that.
  • Here's an example of my terminal ouput with both of those "gotcha's" happening.

Unprotected PEM CHMOD Pem

  • If all goes well then you're logged in!

Setting up your Python Environment

  • Now it's time to set up your python environment with Anaconda. Use wget to download the Anaconda installer to your server

Get Anaconda

  • Run the Bash script. I've will leave everything with its default setting. Anaconda will install everthing in an folder in your home directory.

Run Anaconda

  • After a few minutes the install will finish and tell you to put the folder that was just created at the top of your $PATH. Modify your .bashrc.

Modify Bash

Add Path to Bash

  • Make sure to reload your .bashrc with the source command. You can double check which Python you are using by calling: $ which python

Reload source

  • Say whaaaat? Now you've got a pretty good base to do all your Scientific Computing in Python.

Setting up iPython Notebook

  • We're almost there. I can feel it. We've got a few more steps: Create a iPython Profile for our server; Create a password for our notebook log in; Create a self-signed SSL certificate for HTTPS access; and finally modify our file. Much of (if not all) of this code follows the iPython Notebook doc very closely.

  • From anywhere type: $ ipython profile create nbserver

  • Next, we're going to create a password for your notebook server. I'm going to do everything from within iPython right now. You can access the shell commands by prepending your commands with "!". Some commands like "cd" and "ls" don't need an "!" in front. It's pretty awesome. See "Magic Functions" in the resources section.

  • The output of passwd() is going to be used in the notebook configuration file later. So save/remember it!

Make Password

  • Up next we're going to create a directory in our home folder called "certificates". In this folder we're going to save a self signed SSL certificate. Complete the questions as best you can.

Create SSL Certificate

  • We're going to need the name of the certifcate and the absoulte path for the notebook configuration file.


  • Last, but not least, it's time to modify our file.
  • Cruise over to ~/.ipython/profile_nbserver/ (or whatever you decided to call your profile) and open up the file.

Notebook Config

  • You can either go through the config file and uncomment each of these one by one, or just use the iPython HTML Notebook docs and copy the code to the top of the file like I did. You'll need to change "certfile" and "password" to the values you just got from the previous steps. Change the "port" to 8888.
  • Save!

Launching you iPython Notebook

  • From anywhere run the following: $ ipython notebook inline --profile=nbserver

Server up

  • If you're successful you should have output like the above! WATCH OUT: make sure your server is running at "all ip addresses on your system" rather than just (or something like that). You WILL have a bad time.

Logging in to your Notebook from the Browser

  • In order to log in via the browser we need the Public DNS for our sever. Cruise over to your AWS Console and select your instance from the Instances page. Under description you should find this:

Public DNS

Chrome Warning Safari Warning

  • You're in! Enter your password, create a notebook, and start doing...stuff!


What next?

A few things:

  • Why not associate an Elastic IP to your instance(s)? Now you've got a static ip no matter what kind of instance you start.
  • Use your Elastic IP and set up forwarding from a domain that you own. Instead of having a random IP address (albeit static) you can access your notebook via a memorable domain name. E.g.
  • Create a Snapshot of your AMI. Now you can use this AMI on ANY instance type you like.
  • Create an EBS volume to store all your data/work. Use your newly created Python AMI and run a massive instance for a few hours. Your setup Python setup will be the same but your hardware will be pretty beefy.
  • Dive in to the .ipython folder in your home directory (or where you installed it) and modify your There are lots of options for configuring what packages are imported and what they are called at startup.

Resources and Further Reading

  1. iPython HTML Notebok Documentation
  2. iPython on EC2 Screen Cast
  3. EC2 Screencast on YouTube
  4. Anaconda Download
  5. Anaconda Package Index
  6. iPython Tutorial -> Magic Functions

This comment has been minimized.

BAM-BAM-BAM commented Jul 8, 2013

typo: "ipython notebook inline profile=nbserver" should read "ipython notebook inline --profile=nbserver"

Dashes are missing in the rendered markup.


This comment has been minimized.

jkibele commented Jul 15, 2013

Thanks for the great tutorial. I've got my ipython notebook up and running but I am having one problem. I'm trying to set up an upstart configuration file to start the server and keep it running (currently, whenever I shut down my ssh session, my notebook server stops too). I'm new to using upstart (and I'm not much of a system administrator type anyway) and I can't get my upstart conf file to start the notebook server as the ubuntu user. Things get kind of wonky when upstart starts it as root (largely because Anaconda doesn't get put onto the PATH).

Have you used upstart to start your notebook server? Could you let me know how you put your conf file together?


This comment has been minimized.

rgbkrk commented Aug 23, 2013

Hey @jkibele, I realize this is one month old but thought I'd ask. I'm using supervisord to launch the IPython notebook and keep it running now. Did you figure out something already?


This comment has been minimized.


iamatypeofwalrus commented Sep 1, 2013

Sorry all. Didn't realize that were comments here! I'll fix typos and answer @jkibele as I can.


This comment has been minimized.


iamatypeofwalrus commented Sep 1, 2013

Actually @jkibele there are couple of different routes you can take that don't involve any upstart config file.

The one that I used was simply using Screen to have a detached terminal session running. That way I never had to stay logged in, and I could always have the terminal session that launched the server available at all times.


This comment has been minimized.


iamatypeofwalrus commented Sep 1, 2013

@BAM-BAM-BAM fixed. Thanks! :-]


This comment has been minimized.

sotoseattle commented Oct 12, 2013

Beautiful. Thanks for putting it together.


This comment has been minimized.

stharrold commented Oct 19, 2013

thank you


This comment has been minimized.

momr commented Nov 14, 2013

Thanks for this great Gist

I just wanted to add that, one extra step was needed in my case, in order to connect to my ipython notebook server on port 8888, I had to add new security rule for this port 8888 specifically and apply it on my EC2 instance.

Thanks again


This comment has been minimized.

rgjr commented Nov 23, 2013

This is so awesome, having just gotten started messing around with AWS and IPython! Thanks!


This comment has been minimized.

yeagerm commented Nov 28, 2013

After puzzling about the location of the /.ipython directory, if found it in ~/.config/ipython


This comment has been minimized.

arokem commented Jun 11, 2014

For the real quick-and-dirty, you can skip the anaconda part and get this up and running with a:

sudo apt-get ipython-notebook python-matplotlib python-scipy

This comment has been minimized.

porglezomp commented Aug 17, 2014

I haven't had time to try this, but does it support the inline rendering of the plots?


This comment has been minimized.

theredpea commented Nov 29, 2014

Great tutorial!
Thanks @iamatypeofwalrus,

There's always money in the banana stand!

I made a fork with

  1. new screenshots (Amazon's new UI)
  2. WIndows-focus,
  3. Pitfalls I ran into
    • Writing cert and key to different files
    • Editing instead of
    • Location of openssl.cnf

I preserved as much of your original as possible.

Check it out here


This comment has been minimized.

AlanZZhao commented Feb 13, 2015

Awesome guide. Is there anyway to establish a permanent public DNS for my instance? I have infrequently large requests that require computing power, but I shut down my server otherwise. It's getting a little annoying resending out the URL every single time.

Also - keep in mind I'm a total AWS noob... so please dumb down the answer :)


This comment has been minimized.

sofiatti commented Mar 6, 2015

Thank you so much!!!


This comment has been minimized.


iamatypeofwalrus commented Mar 6, 2015


Off the top of my head you could use Route53 for your DNS with a domain like or even just a subdomain like

Have that domain (or subdomain!) point to an elastic IP.

Create a script for starting up your compute cloud with the AWS SDK in your favorite language. This script should: create a new server instance and associate it with your elastic ip. Now your domain points to your server! Your shutdown script does the reverse: deallocate a server.

Cons: you have to keep your elastic ip around and AWS charges.

You could allocate an elastic ip in your startup script, but that's a call you'll have to make depending on how fast Route53 propagates that information.


This comment has been minimized.

tildebyte commented Mar 18, 2015

Instead of the Ubuntu image, use (page also includes info on Azure and Docker) and skip the Python install/setup step. Caveat: I don't know what is included/configured in that image, so all of the ipython stuff might still apply.


This comment has been minimized.

tildebyte commented Mar 18, 2015

Also, one should probably:

  • Run:
    • Update (conda update foo):
    • conda - Highly recommended to get the latest Anaconda package manager. Also will probably update to latest Python / openssl / maybe other important stuff.
    • ipython - New version 3.0 has some cool new features (also requires jsonschema package).
    • sympy - New version 0.7.6 has cool new features and many bug fixes.
    • numpy / scipy / matplotlib
    • Install (conda install foo):
      • terminado - A nice addition to ipython 3.0 which will run a server-side terminal session in a browser tab
      • Whatever else one might want.

I highly recommend updating ipython to 3.0. In addition to lots of bug fixes, ipython is now powered by the Jupyter backend, which allows many different frontends (Oh, my!).


This comment has been minimized.

drevicko commented Apr 27, 2015

@imatypeofwalrus: I find byobu much easier to use than screen: do sudo apt-get install byobu, then byobu gives you a terminal that can stay alive after you're gone. Exit byobu with F6, get byobu help with F9, F2 creates another byobu terminal tab, F3 and F4 swich byobu tabs. (don't exit by logging out of the terminal - you want it to stay alive!). You can run ipython in a tab and leave it going when your'e gone :)


This comment has been minimized.

noelmas commented Jun 4, 2015

I just want to say how fantastically useful this was, super clear


This comment has been minimized.

jkarnows commented Jun 21, 2015

This was absolutely wonderful. Thanks!

One question I have is how to create multiple notebook instances on the same AWS server but accessed on different ports. I've tried multiple ways to get this to work, but nothing seems to do the trick (and I can't find an appropriate source online). Any suggestions? Thanks!

Edit: I figured it out. You have to add a new inbound rule in the security settings for the other ports.


This comment has been minimized.

haoxue1 commented Sep 14, 2015

Just wanna thank you very much!


This comment has been minimized.

MridulS commented Sep 15, 2015

Just stumbled on this, looks great :)
I tried doing something similar with a digitalocean vm


This comment has been minimized.

townie commented Oct 31, 2015

#Configuration file for ipython-notebook.

c = get_config()

#ipython Kernel Configs
c.IPKernelApp.pylab = 'inline'
c.NotebookApp.certfile = '~/.ssh/mycert.pem'
c.NotebookApp.ip = '*'
c.NotebookApp.open_browser = False
c.NotebookApp.password = u'sha1:bcd259ccf... your hashed password here'
# It's a good idea to put it on a known, fixed port
c.NotebookApp.port = 8888

This comment has been minimized.

townie commented Oct 31, 2015

for Jupyter AKA ipython 4.0 you need to use
jupyter-notebook --config='~/.ipython/profile_nbserver/'


This comment has been minimized.

haimingzhao commented Nov 18, 2015

When I type: ipython notebook inline --profile=nbserver
I got the warning
" Unrecognized alias: '--profile=nbserver', it will probably have no effect. "

I need to use
ipython notebook ./ inline --config="~/.ipython/profile_nbserver/"

and it seems to work


This comment has been minimized.

amolsharma99 commented Nov 19, 2015

completed path in config worked for me as well.
Thanks !


This comment has been minimized.

jgharris7 commented Nov 22, 2015

Fails on a couple of fronts:

  1. in my nbserver directory there is and but no

I created the and put the stuff that you instructed in.

I then tried:
python notebook inline --profile=nbserver
and got.
[W 21:57:28.352 NotebookApp] Unrecognized alias: '--profile=nbserver', it will probably have no effect.
[C 21:57:28.353 NotebookApp] No such file or directory: /home/ubuntu/.ipython/profile_nbserver/inline


This comment has been minimized.

carolingfish commented Nov 23, 2015

Thanks! this guide was super helpful. I was total beginner to UNIX too.
For others who are new to UNIX like me

  1. To edit config files you can use vi
    in vi, you can toggle between editing mode/command mode by ESC. you can start editing by i
    to exit without save :q! enter to exit with save :x
  2. How to get full path of file in command line
  3. missing
    i had this issue, but ended up modifying the jupyter config file instead.
    I guess this doesn't really utilize profiles, but i didn't need in my case.

This comment has been minimized.

sushiyan commented Dec 11, 2015


After i have tried to launch the ipython notebook, the webpage is not simply not available at ""

Anyone know how tot solve this problem?

[ec2-user@ip-172-31-31-24 ~]$ ipython notebook --config="/home/ec2-user/.ipython/profile_nbserver/"
[I 07:25:13.993 NotebookApp] Serving notebooks from local directory: /home/ec2-user
[I 07:25:13.994 NotebookApp] 0 active kernels
[I 07:25:13.994 NotebookApp] The IPython Notebook is running at: https://[all ip addresses on your system]:8000/
[I 07:25:13.994 NotebookApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).


This comment has been minimized.

jonschull commented Jan 18, 2016

I got all the way to the end but got the same problem as Sushiyan above.


This comment has been minimized.

Abhishek-Ravichandran commented Mar 3, 2016

@jonschull: Try changing http to https. Also make sure the inbound rules on your instance are set properly to allow connections to the particular port on which your server is running.


This comment has been minimized.

mramanathan commented May 8, 2016

Thanks for posting your notes, it was quite handy !



This comment has been minimized.

jeremykohn commented Aug 22, 2016

If you find that the configuration file is missing, here's why:

Things have changed in jupyter since "the big switch", where notebook configurations have migrated to the .jupyter folder....

if your notebook config is missing (which was my case when starting ipython to create a profile), you can generate a jupyter config with the following:

jupyter notebook --generate-config

this should create a ~/.jupyter/ file with relevant notebook settings ready to be uncommented/modified such as ports and passwords.

Hat tip:

Note: This advice is a little different from what townie mentions above. It worked for me, though.

@jgharris7 @carolingfish


This comment has been minimized.

jeremykohn commented Aug 22, 2016

I had the same issue as @haimingzhao and @amolsharma99....

Unrecognized alias: '--profile=nbserver', it will probably have no effect.

This is because Jupyter Notebook no longer supports profiles, only config.

See the comments by marbre and Carreau here: ipython/ipython#8769


This comment has been minimized.

Vikramank commented Aug 26, 2016

Thanks for a great article. Unfortunately after going through all the steps successfully, I am unable to create a new notebook. It returns me an error :Permission denied: Untitled.ipynb

Any suggestion?



This comment has been minimized.

jeremykohn commented Sep 1, 2016

@Vikramank If you don't have the right permissions for a certain file or directory, you may need to change its permissions or its owner. To do this on the command line, use chmod or chown respectively.

Or sometimes you can override permissions. Just precede a command with the word sudo and that'll get things done.


This comment has been minimized.

subhadipna commented Oct 15, 2016

Great article !!! also thanks to Townie for updated line to configure notebook.


This comment has been minimized.

hkorre commented Nov 25, 2016

Awesome article!


This comment has been minimized.

angelinawilliams commented Jan 24, 2017

Very nice and informative, preparing for AWS certification, recently joined for amazon aws tutorial, can any one suggest me some books and videos on this.


This comment has been minimized.

Dtrycode commented Jul 29, 2017

Thank you! Could you fix the problems of the images? I think they are all not found.


This comment has been minimized.

awaiskaleem commented Aug 27, 2017

Exactly what i was looking for. How feasible is it for you to make a video tutorial on youtube for it?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment