Skip to content
Create a gist now

Instantly share code, notes, and snippets.

Embed URL


Subversion checkout URL

You can clone with
Download ZIP
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

  • Using your public DNS go to your fav browser and type: https://your-Instance's-public-DNS:8888

  • If successfull you'll get a warning about the self signed certificate. It's ok! Click Continue.

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

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

Dashes are missing in the rendered markup.


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?


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?


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


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.


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


Beautiful. Thanks for putting it together.


thank you


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 is so awesome, having just gotten started messing around with AWS and IPython! Thanks!


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


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

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


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


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 :)


Thank you so much!!!



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.


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.


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!).


@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 :)


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


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.


Just wanna thank you very much!


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

#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

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


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


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


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


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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.