How to run Jupyter notebook on a remote server

JeanBean
Thu, 04 Mar 2021 23:02:54 +0000
How-Tos, jupyter

You can run Jupyter server on a remote machine instead of your local machine.

Replace the server port number with the port you want for your remote machine:

remoteuser@remotehost: jupyter notebook --no-browser --port=9888 [default 8888]

Use ssh to open a path between your local machine and the remote machine. The first localhost port below is the client side of ssh on your local machine:

localuser@localhost: ssh -N -f -L localhost:9000:localhost:9888 -i "keypair.pem" ubuntu@ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com

Replace the address after keypair.pem with the ssh login username for your remote server. The second localhost port is the port on the distant end, where you started your Jupyter server.
Now you can navigate to your remote Jupyter server from your local Web browser:

http://localhost:9000

If you are using AWS for your remote server, you can generate the keypair.pem file at AWS.