Running a Jupyter Notebook Server
Some of the tutorials were out of date in places, so I decided to write my own how-to guide to running a remote Jupyter Notebook Server.
Download the Anaconda installation script
Can find it here.
The link to the correct bash script for me was this.
SFTP the script to your remote server:
sftp username@remote_server_url
#lls/lcd into where the installation script is located on local computer
put Anaconda3-5.0.1-Linux-x86_64.sh
exit
Run the installation script
ssh username@remote_server_url
chmod +x ./Anaconda3-5.0.1-Linux-x86_64.sh # give script access
./Anaconda3-5.0.1-Linux-x86_64.sh # run script
Open a new terminal window on remote server and test
source .bashrc # may be necessary to use jupyter/python/conda commands
conda list # output should be all packages installed
python # should open Python 3.6.X session from anaconda
Set up Notebook Server config settings
jupyter notebook --generate-config # create config file
cd .jupyter
vim jupyter_notebook_config.py
By default, all lines are commented out. To run a remote server, you’ll want at least these lines in:
c.NotebookApp.open_browser = False
c.NotebookApp.port = 8888 # define a port to connect on
Your security preferences for tokens and passwords may vary (see here.
Something to highlight that could be an issue:
c.NotebookApp.ip = '*' # to allow bind on all public server ip's
If this isn’t changed, the server will by default only accept connections from localhost.
Something from the jupyter docs that I highly recommend is having a subdirectory solely for ipython files, and only starting the notebooks server from within that subdirectory. To do this:
mkdir ipython # in remote server
c.NotebookApp.base_url = '/ipython/'
Start Server
jupyter notebook # on remote server
Reminder: if you have a subdirectory as a base_url like I recommended above, run this command from within the subdirectory.
Now, you should be able to access the jupyter notebook server at http://your_public_server.com:8888/ipython/, or https://your_public_server.com:8888/ipython/ depending on if you went through the SSL step.
To see what URL’s your server is accepting connections on, open a new remote server terminal window, and run jupyter notebook list.
To keep running the server after you exit your remote server session, start the server with nohup jupyter notebook.
Other Notes
If you’re trying to access the remote notebook server, and aren’t getting through at all (no output at all from notebook server), it’s most likely a firewall issue - you’ll need root access, but try sudo iptables -L and see if you can find a rule blocking external connections.