localhost:8888 is the default port of Jupyter Notebook and JupyterLab. Running jupyter lab or jupyter notebook starts a server on http://localhost:8888 and opens your browser with a one-time token in the URL. If the page refuses to connect, the server isn't running; if it asks for a password or token, the server is running and wants you to log in.
What runs on port 8888
| Tool | Command | Notes |
|---|---|---|
| JupyterLab | jupyter lab | Default 8888 |
| Jupyter Notebook | jupyter notebook | Default 8888 |
| Jupyter Docker Stacks | docker run -p 8888:8888 quay.io/jupyter/scipy-notebook | Token printed in container logs |
| VS Code Jupyter (remote kernel) | Connects to an existing server | Uses the server's URL and token |
A second server moves to 8889, 8890 and so on.
Fix "localhost:8888 refused to connect"
- Is the server running? The terminal shows
Jupyter Server ... is running at: http://localhost:8888/lab?token=.... If you closed that terminal, the server stopped with it. - List running servers:
jupyter server list
This shows each server's actual port and token. On older installs usejupyter notebook list. - Docker. Use the
http://127.0.0.1:8888/lab?token=...line fromdocker logs <container>. The hostname-based URL in the logs points to the container's own name, which your browser can't resolve. - WSL2. Recent WSL forwards
localhostto Windows. If it doesn't, start with--ip 0.0.0.0and use the WSL IP.
"Password or token" page
That page means you reached Jupyter without the token. Copy the full URL including ?token=... from the terminal or jupyter server list, or set a password once with jupyter server password. Don't "fix" this by disabling authentication. A Jupyter server runs arbitrary code as your user, so anyone who can reach it without a token owns the machine.
Find and free a busy port 8888
jupyter server stop 8888 # clean shutdown
# or find the process
lsof -i :8888
kill -9 $(lsof -ti :8888)
# Windows
netstat -ano | findstr :8888
taskkill /PID <pid> /F
Pick a port explicitly with jupyter lab --port 8899, or set c.ServerApp.port = 8899 in jupyter_server_config.py.
Open Jupyter from another machine
The common case is Jupyter running on a GPU box or cloud VM. Two options:
SSH tunnel (best when you have SSH):
# on the server
jupyter lab --no-browser --port 8888
# on your laptop
ssh -L 8888:localhost:8888 user@gpu-box
Then open http://localhost:8888 locally with the token. Nothing new is exposed.
LAN access: jupyter lab --ip 0.0.0.0 --no-browser and open http://SERVER-IP:8888/?token=.... Only on a network you trust, and only with the token on.
Share Jupyter over a public URL
When there's no SSH path (the box is behind NAT, or a collaborator doesn't have an account on it), a tunnel gives the server an HTTPS address without opening inbound ports:
relay connect --name team-notebook http://localhost:8888
Keep token or password authentication enabled. The tunnel only makes the server reachable; Jupyter's own login is what stops strangers running code on your machine. If notebooks load but kernels keep disconnecting, the WebSocket connection to /api/kernels/... is failing; check that nothing between the browser and Jupyter strips WebSocket upgrades. Dotscience runs thousands of tunnels like this for hosted data science environments.
