Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4072 pages
Servers, nginx and Docker

Jupyter Notebook will not start: permission denied

ErrorPermission denied

Short answer

Jupyter writes connection files and settings into your user folders every time it starts. It fails with permission denied when those folders belong to root, usually after an earlier sudo run, or when the runtime location is not writable for your account. Give the folders back to your user, or point Jupyter at a directory you own.

  • Applies to Jupyter Notebook 7, jupyter_core 5, Ubuntu 24.04
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Fix it fast

  1. 1Find out which cause you have

    List who owns the Jupyter folders. Anything owned by root is the problem.

    ls -ld ~/.jupyter ~/.local/share/jupyter ~/.local/share/jupyter/runtime
    echo "$JUPYTER_RUNTIME_DIR"
  2. 2Match what you see, then jump to its fix

    1. 1ls shows root as owner of ~/.jupyter or ~/.local/share/jupyterThe Jupyter folders are owned by rootFix
    2. 2The error names a path under a runtime folder, and chown does not apply (shared home, read-only mount, container)The runtime directory cannot be written by your accountFix

What does the error look like?

  • Permission denied

Cause 1 of 2

The Jupyter folders are owned by root

1Check

Jupyter keeps config in ~/.jupyter and data, with a runtime subfolder, in ~/.local/share/jupyter on Linux. If you ever ran jupyter with sudo, root created files there that your normal user cannot change.

find ~/.jupyter ~/.local/share/jupyter ! -user "$USER" 2>/dev/null | head

2Fix

Give the folders back to your user, recursively, then start Jupyter without sudo.

sudo chown -R "$USER":"$(id -gn)" ~/.jupyter ~/.local/share/jupyter

3Verify

The first command lists nothing, and Jupyter starts.

find ~/.jupyter ~/.local/share/jupyter ! -user "$USER" 2>/dev/null | head
jupyter notebook --no-browser

Confirmed by docs.jupyter.org

Did this fix it?

Cause 2 of 2

The runtime directory cannot be written by your account

1Check

Runtime files live in the runtime subfolder of the data directory unless JUPYTER_RUNTIME_DIR says otherwise.

echo "$JUPYTER_RUNTIME_DIR"; ls -ld ~/.local/share/jupyter/runtime

2Fix

Point JUPYTER_RUNTIME_DIR at a folder you own, for this shell or in your profile.

mkdir -p "$HOME/jupyter-runtime"
export JUPYTER_RUNTIME_DIR="$HOME/jupyter-runtime"

3Verify

The variable shows your folder, and the server starts.

echo "$JUPYTER_RUNTIME_DIR"
jupyter notebook --no-browser

Confirmed by docs.jupyter.org

Did this fix it?

How do I stop it coming back?

  • Never start Jupyter with sudo; install packages in a virtual environment you own.
  • In Docker, run the notebook as a normal user and mount the data directory with that user's ownership.
  • Keep the Jupyter folders out of shared or read-only locations, or move them with JUPYTER_DATA_DIR.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Related fixes

Servers

dnf cannot install MySQL on Amazon Linux 2023

dnf cannot find a mysql-server package on Amazon Linux 2023

Amazon Linux 2023 documents MariaDB, not MySQL, as its database server, with packages named mariadb105 and mariadb105-server.

3 causes, each with a fix

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.