Appearance
Port Forwarding & Jupyter
When you run Jupyter Notebooks on a remote server, they usually start on that server’s local port (like localhost:8888). But your browser on your laptop can’t open that directly — that’s where port forwarding comes in.
Port forwarding lets you tunnel a connection from your local machine to the remote one, so you can open Jupyter running on the server right in your local browser.
It’s simple once you do it once or twice — and it’s super handy for remote data analysis, visualization, or FEniCS experiments.
Why Port Forwarding?
When you’re logged into a server via SSH, that connection is already secure. Port forwarding just extends it a bit — allowing your local browser to reach something running on the server (like Jupyter, TensorBoard, or a web dashboard).
So instead of transferring files back and forth, you can:
- Run Jupyter directly on the remote server
- Keep all your heavy data and code there
- View results through your local web browser
It’s the best way to work remotely without losing the interactive feel.
How to Set It Up
Step 1 — SSH into your remote machine with port forwarding
On your local terminal, type:
bash
ssh -L 8888:localhost:8888 username@server_ipThis means:
“Take my local port 8888 and link it securely to port 8888 on the remote server.”
Step 2 — Start Jupyter on the remote machine
Once connected, start Jupyter (no browser option):
bash
jupyter notebook --no-browser --port=8888You’ll see something like:
To access the notebook, open this file in a browser:
http://localhost:8888/?token=abcd1234...Step 3 — Open it locally
Now open your local browser and visit:
http://localhost:8888Paste in the token from your remote terminal — and boom, you’re connected to Jupyter running on your remote server.
Notes
- You can change the port if needed — just replace
8888with any free port (e.g.8890). - Always use the same port number on both sides of the
-Loption. - If you use VS Code Remote-SSH, it can automatically forward ports for you (you’ll see a “Port” tab appear).
- Don’t use
--ip=0.0.0.0unless you know what you’re doing — that makes the notebook accessible to others on the network. - For repeated use, you can add the port forwarding line to your SSH config.
Summary
- Port forwarding lets you open remote Jupyter Notebooks in your local browser securely through SSH.
- It keeps all code and data on the server but feels just like working locally.
- One simple command —
ssh -L 8888:localhost:8888 user@server— is all it takes.
Once you get used to it, running Jupyter remotely becomes second nature — smooth, secure, and perfect for heavy simulations or data analysis.