无法通过Anaconda启动Jupyter Lab,遇端口占用及404错误
First, let's recap the error you're encountering:
[I 01:37:29.009 LabApp] The port 8888 is already in use, trying another port.
[I 01:37:29.010 LabApp] The port 8889 is already in use, trying another port.
[I 01:37:29.010 LabApp] The port 8890 is already in use, trying another port.
[I 01:37:29.011 LabApp] The port 8891 is already in use, trying another port.
[I 01:37:29.011 LabApp] The port 8892 is already in use, trying another port.
[I 01:37:29.031 LabApp] JupyterLab beta preview extensio...
This issue almost always stems from leftover Jupyter Lab/Notebook processes running in the background (even if you closed the browser window) that are hogging those default ports. Here are straightforward fixes to resolve this:
1. Kill Stuck Jupyter Processes
On Windows:
- Open Command Prompt or PowerShell.
- Run this to find all Jupyter-related processes:
tasklist | findstr "jupyter" - You’ll get a list of processes with their PID numbers. Kill each one with:
Replacetaskkill /F /PID <your_pid_number><your_pid_number>with the actual number from the list.
On macOS or Linux:
- Open Terminal.
- Run this to locate processes using Jupyter’s default ports:
(Swap 8888 with any port mentioned in your error if needed.)lsof -i :8888 - Kill the process with:
Use the PID from the output here.kill -9 <pid_number>
For a quicker cleanup, kill all Jupyter processes at once:
pkill -f jupyter
2. Launch Jupyter Lab on a Custom Port
If killing processes feels like a hassle, skip the default ports entirely by specifying an unused one when starting Jupyter. Open your Anaconda Prompt (or Terminal) and run:
jupyter lab --port 9000
Replace 9000 with any unused port number (like 9001, 9002—pick something outside the 8888-8892 range). This bypasses the conflict immediately.
3. Check for Non-Jupyter Apps Using the Ports
Sometimes other tools (web servers, databases, or even background services) might be using those ports. Verify this with:
- Windows:
netstat -ano | findstr ":8888" - macOS/Linux:
netstat -tulpn | grep :8888
If the process isn’t Jupyter, close that app or adjust its port settings to free up the space.
After trying one of these methods, restart Jupyter Lab via Anaconda—it should launch without the port conflict or 404 error.
内容的提问来源于stack exchange,提问作者Nuno Miguel Esguelha

