You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Windows11下Anaconda环境Jupyter启动后无法连接localhost求助

Jupyter Lab启动后localhost拒绝连接排查方案

问题描述

使用Jupyter Notebook/Lab超过5年,此前无启动问题。今日通过命令提示符启动Jupyter Lab后,服务器日志显示正常运行,浏览器弹出localhost标签页,但提示:

无法访问此网站
localhost拒绝连接。

详细启动日志

(base) C:\>jupyter lab
[I 2024-02-26 10:58:00.260 ServerApp] jupyter_server_fileid | extension was successfully linked.
[I 2024-02-26 10:58:00.260 ServerApp] jupyter_server_ydoc | extension was successfully linked.
[I 2024-02-26 10:58:00.260 ServerApp] jupyterlab | extension was successfully linked.
[I 2024-02-26 10:58:00.260 ServerApp] nbclassic | extension was successfully linked.
[I 2024-02-26 10:58:00.512 ServerApp] notebook_shim | extension was successfully linked.
[I 2024-02-26 10:58:00.512 ServerApp] panel.io.jupyter_server_extension | extension was successfully linked.
[I 2024-02-26 10:58:00.527 ServerApp] notebook_shim | extension was successfully loaded.
[I 2024-02-26 10:58:00.534 FileIdExtension] Configured File ID manager: ArbitraryFileIdManager
[I 2024-02-26 10:58:00.534 FileIdExtension] ArbitraryFileIdManager : Configured root dir: C:
[I 2024-02-26 10:58:00.534 FileIdExtension] ArbitraryFileIdManager : Configured database path: C:\Users\amirhhm\AppData\Roaming\jupyter\file_id_manager.db
[I 2024-02-26 10:58:00.534 FileIdExtension] ArbitraryFileIdManager : Successfully connected to database file.
[I 2024-02-26 10:58:00.534 FileIdExtension] ArbitraryFileIdManager : Creating File ID tables and indices with journal_mode = DELETE
[I 2024-02-26 10:58:00.534 ServerApp] jupyter_server_fileid | extension was successfully loaded.
[I 2024-02-26 10:58:00.534 ServerApp] jupyter_server_ydoc | extension was successfully loaded.
[I 2024-02-26 10:58:00.534 LabApp] JupyterLab extension loaded from C:\Users\amirhhm\AppData\Local\anaconda3\Lib\site-packages\jupyterlab
[I 2024-02-26 10:58:00.534 LabApp] JupyterLab application directory is C:\Users\amirhhm\AppData\Local\anaconda3\share\jupyter\lab
[I 2024-02-26 10:58:00.534 ServerApp] jupyterlab | extension was successfully loaded.
[I 2024-02-26 10:58:00.534 ServerApp] nbclassic | extension was successfully loaded.
[I 2024-02-26 10:58:00.534 ServerApp] panel.io.jupyter_server_extension | extension was successfully loaded.
[I 2024-02-26 10:58:00.543 ServerApp] Serving notebooks from local directory: C:\
[I 2024-02-26 10:58:00.543 ServerApp] Jupyter Server 1.23.4 is running at:
[I 2024-02-26 10:58:00.543 ServerApp] http://localhost:8888/lab?token=bf71e43526056e848f03a66e9ec52e31d997b9b2f41940af
[I 2024-02-26 10:58:00.543 ServerApp]  or http://127.0.0.1:8888/lab?token=bf71e43526056e848f03a66e9ec52e31d997b9b2f41940af
[I 2024-02-26 10:58:00.543 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 2024-02-26 10:58:00.575 ServerApp]

    To access the server, open this file in a browser:
        file:///C:/Users/amirhhm/AppData/Roaming/jupyter/runtime/jpserver-3300-open.html
    Or copy and paste one of these URLs:
        http://localhost:8888/lab?token=bf71e43526056e848f03a66e9ec52e31d997b9b2f41940af
     or http://127.0.0.1:8888/lab?token=bf71e43526056e848f03a66e9ec52e31d997b9b2f41940af

(base) C:\>

已尝试的解决方法

  • 重启电脑
  • 更新Anaconda、Jupyter Notebook和Jupyter Lab
  • 卸载并重装Anaconda
  • 在其他浏览器中打开localhost链接
  • 在其他conda环境中启动Jupyter

环境信息

  • Windows 11系统
  • Anaconda版本2.5.0
  • Jupyter Lab版本3.6.3
  • Jupyter Notebook版本6.5.4

排查步骤

1. 确认端口是否被占用

  • 打开命令提示符,执行命令:netstat -ano | findstr :8888
  • 如果输出结果中有其他进程占用8888端口,记录PID,打开任务管理器结束对应进程,再重新启动Jupyter Lab
  • 或者启动时指定未被占用的端口:jupyter lab --port 8889

2. 检查防火墙和杀毒软件拦截

  • 临时关闭Windows Defender防火墙或第三方杀毒软件,重新启动Jupyter Lab尝试访问
  • 如果可以访问,需将Jupyter相关程序或localhost:8888添加到防火墙允许列表

3. 验证本地网络配置

  • 在命令提示符中执行:ping localhost和ping 127.0.0.1,确认本地回环地址正常响应
  • 检查hosts文件(路径:C:\Windows\System32\drivers\etc\hosts),确保存在127.0.0.1 localhost的映射,且未被注释

4. 确认Jupyter服务是否持续运行

  • 启动Jupyter Lab后不要关闭命令提示符,打开任务管理器,查看是否有python.exe或jupyter-lab.exe进程在运行
  • 如果进程不存在,说明服务启动后立即崩溃,执行jupyter lab --debug启动,查看详细调试日志定位崩溃原因

5. 重置Jupyter配置

  • 执行jupyter server --generate-config生成默认配置文件(已存在会提示覆盖)
  • 备份原配置文件后,删除C:\Users\amirhhm\.jupyter目录下的配置文件,重新启动Jupyter Lab

6. 检查权限问题

  • 尝试以管理员身份运行命令提示符,再启动Jupyter Lab
  • 检查Jupyter运行目录(C:\)的读写权限,确保当前用户有足够权限访问该目录

内容的提问来源于stack exchange,提问作者Amir H

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.29 08:14:54