JupyterLab (the modern successor to Jupyter Notebook) is the standard interactive environment for Python data analysis, machine learning experiments, teaching and quick scripting. Running it on a VPS gives you an always-on notebook server: long jobs keep running when your laptop sleeps, data stays next to the compute, and you can reach it from any browser.

Requirements

  • 1–2 vCPU and 2 GB RAM for light analysis. Data work is often RAM-bound: pandas typically needs several times the size of the dataset in memory. See how much RAM a VPS needs.
  • For deep learning training you want a GPU. A CPU VPS is fine for data prep, small models and inference.

Install in a virtual environment

sudo apt install -y python3-venv python3-pip
python3 -m venv ~/jupyter
. ~/jupyter/bin/activate
pip install jupyterlab pandas numpy matplotlib

Set a password (stored hashed in ~/.jupyter/jupyter_server_config.json):

jupyter lab password

See Python virtual environments.

Option 1: SSH tunnel (simplest and safest)

jupyter lab --no-browser --ip 127.0.0.1 --port 8888
# on your computer:
ssh -L 8888:127.0.0.1:8888 user@server
# then open http://localhost:8888

Nothing is exposed to the internet. See SSH tunnelling.

Run it as a service

# /etc/systemd/system/jupyter.service
[Unit]
Description=JupyterLab
After=network.target

[Service]
User=alice
WorkingDirectory=/home/alice/notebooks
ExecStart=/home/alice/jupyter/bin/jupyter lab --no-browser --ip 127.0.0.1 --port 8888
Restart=on-failure

[Install]
WantedBy=multi-user.target
sudo systemctl daemon-reload && sudo systemctl enable --now jupyter

Kernels keep running across browser disconnects. That’s the point of a server. See systemd services.

Option 2: Nginx with HTTPS

If you need browser access without a tunnel:

server {
    server_name jupyter.example.com;
    client_max_body_size 200M;
    location / {
        proxy_pass http://127.0.0.1:8888;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_read_timeout 86400;
    }
    # listen 443 ssl; certbot --nginx -d jupyter.example.com
}

WebSockets are required: kernels talk over them. Add to ~/.jupyter/jupyter_server_config.py:

c.ServerApp.trust_xheaders = True
c.ServerApp.allow_remote_access = True

Security warning: a Jupyter session is arbitrary code execution as that user. Use a strong password, HTTPS only, and ideally a VPN or SSO in front. Scanners look for open Jupyter servers to install crypto miners. See Tailscale and Nginx basic auth.

Kernels and environments

Register other virtual environments (or conda envs) as kernels:

python3 -m venv ~/envs/ml && ~/envs/ml/bin/pip install ipykernel scikit-learn
~/envs/ml/bin/python -m ipykernel install --user --name ml --display-name "Python (ml)"

Kernels exist for R (IRkernel), Julia, and others too.

JupyterHub for teams

For several users, use JupyterHub: each user gets their own server and login (Linux users, OAuth/GitHub, or LDAP). The Littlest JupyterHub (TLJH) sets this up on a single VPS in one command, with HTTPS and per-user memory/CPU limits. Use it for classrooms and small data teams.

Resource management

  • Long jobs: run them in the background, and save results to disk. Notebooks aren’t a job scheduler, so convert heavy jobs into scripts with jupyter nbconvert --to script, and run them with cron or systemd.
  • Watch memory: an out-of-memory kernel dies silently. Add swap as a safety net. See swap and htop.
  • Shut down idle kernels: c.MappingKernelManager.cull_idle_timeout = 3600.

Backups

Notebooks are files: keep them in Git (with outputs stripped, using nbstripout) and back up the data directory. See backup strategy.

Quick reference

Task Command
Install pip install jupyterlab (in a venv)
Set password jupyter lab password
Run locally bound jupyter lab --no-browser --ip 127.0.0.1
Tunnel ssh -L 8888:127.0.0.1:8888 user@server
Add a kernel python -m ipykernel install --user --name X

Related: code-server and Whisper transcription server.

  • Development
  • Python
  • Self-Hosting