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

C# Selenium ChromeDriver 103.0.5060.5300报Chrome无法访问问题求助

C# Selenium调用Chrome持续报"Chrome not reachable"错误

问题现象

  • 异常自6月29日左右开始出现,最初触发超时错误,调整部分配置后持续返回Chrome not reachable报错
  • 已查阅大量公开的同类问题解决方案,逐一尝试后均未修复问题
  • 常规运行时会添加--headless无头模式参数,排查时移除该参数观察运行状态:Chrome浏览器窗口可正常弹出,但始终无法导航到目标URL
  • 当前使用的Chrome浏览器与ChromeDriver版本均为103.0.5060.5300
  • 网传通用解决方案添加no-sandbox/--no-sandbox启动参数已尝试,无任何改善效果

相关代码

驱动初始化代码

注:所有注释掉的代码行均为已尝试过的解决方案,未注释部分为此前可长期正常运行的原始代码

public ChromeHeadless()
{
    //var service = ChromeDriverService.CreateDefaultService();
    //service.LogPath = "D:\\chromedriver.log";
    //service.EnableVerboseLogging = true;
    ChromeOptions chromeOptions = new ChromeOptions();
    chromeOptions.PageLoadStrategy = PageLoadStrategy.Normal;
    //chromeOptions.SetLoggingPreference(LogType.Browser, LogLevel.All);
    chromeOptions.AddArgument("--headless");
    //chromeOptions.AddArgument("--no-sandbox");
    //chromeOptions.SetLoggingPreference(LogType.Browser, LogLevel.All);
    driver = new ChromeDriver(chromeOptions);
    //driver = new ChromeDriver(service, chromeOptions, TimeSpan.FromMinutes(3));
    //driver = new ChromeDriver(service, chromeOptions);
}

页面导航代码

当前页面加载超时设置为120秒,常规配置为60秒:

private void NavigateToURL(string url)
{
    if (driver == null) throw new Exception("请重新创建实例,相关资源已被释放。");
    driver.Manage().Timeouts().PageLoad = new TimeSpan(0, 0, 0, Core.Properties.Settings.Default.SeleniumPageLoadTimeout, 0);
    driver.Manage().Timeouts().AsynchronousJavaScript = new TimeSpan(0, 0, 0, Core.Properties.Settings.Default.SeleniumAsyncJSTimeout, 0);
    driver.Navigate().GoToUrl(url);
}

错误追踪日志

[信息]: 正在启动ChromeDriver 103.0.5060.53 (a1711811edd74ff1cf2150f36ffa3b0dae40b17f-refs/branch-heads/5060@{#853}),监听端口56389
[信息]: 请查阅ChromeDriver安全相关注意事项,保障驱动运行安全。
[信息]: [9643e0a93623ae715a18e39a50665f01] 执行InitSession命令 {
   "capabilities": {
      "firstMatch": [ {
         "browserName": "chrome",
         "goog:chromeOptions": {
            "args": [ "--headless", "no-sandbox" ]
         },
         "goog:loggingPrefs": {
            "browser": "ALL"
         },
         "pageLoadStrategy": "normal"
      } ]
   }
}
[信息]: 写入偏好配置文件: {
   "alternate_error_pages": {
      "enabled": false
   },
   "autofill": {
      "enabled": false
   },
   "browser": {
      "check_default_browser": false
   },
   "distribution": {
      "import_bookmarks": false,
      "import_history": false,
      "import_search_engine": false,
      "make_chrome_default_for_user": false,
      "skip_first_run_ui": true
   },
   "dns_prefetching": {
      "enabled": false
   },
   "profile": {
      "content_settings": {
         "pattern_pairs": {
            "https://*,*": {
               "media-stream": {
                  "audio": "Default",
                  "video": "Default"
               }
            }
         }
      },
      "default_content_setting_values": {
         "geolocation": 1
      },
      "default_content_settings": {
         "geolocation": 1,
         "mouselock": 1,
         "notifications": 1,
         "popups": 1,
         "ppapi-broker": 1
      },
      "password_manager_enabled": false
   },
   "safebrowsing": {
      "enabled": false
   },
   "search": {
      "suggest_enabled": false
   },
   "translate": {
      "enabled": false
   }
}
[信息]: 写入本地状态文件: {
   "background_mode": {
      "enabled": false
   },
   "ssl": {
      "rev_checking": {
         "enabled": false
      }
   }
}
[信息]: 无法切换为美式键盘布局,部分按键可能会被错误解析
[信息]: 启动Chrome: "C:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --allow-pre-commit-input --disable-background-networking --disable-backgrounding-occluded-windows --disable-client-side-phishing-detection --disable-default-apps --disable-hang-monitor --disable-popup-blocking --disable-prompt-on-repost --disable-sync --enable-automation --enable-blink-features=ShadowDOMV0 --enable-logging --headless --log-level=0 --no-first-run --no-sandbox --no-service-autorun --password-store=basic --remote-debugging-port=0 --test-type=webdriver --use-mock-keychain --user-data-dir="C:\Windows\TEMP\scoped_dir6296_1256668697" data:,
[调试]: DevTools HTTP请求: http://localhost:56392/json/version
[调试]: DevTools HTTP请求失败
[调试]: DevTools HTTP请求: http://localhost:56392/json/version
[调试]: DevTools HTTP请求失败
[调试]: DevTools HTTP请求: http://localhost:56392/json/version
[调试]: DevTools HTTP请求失败
[调试]: DevTools HTTP请求: http://localhost:56392/json/version
[调试]: DevTools HTTP请求失败
[调试]: DevTools HTTP请求: http://localhost:56392/json/version
[调试]: DevTools HTTP请求失败
[调试]: DevTools HTTP请求: http://localhost:56392/json/version
[调试]: DevTools HTTP请求失败
[信息]: 连接Chrome失败,正在尝试终止进程
[信息]: [9643e0a93623ae715a18e39a50665f01] InitSession命令响应错误 chrome not reachable
[调试]: 日志类型'driver'销毁时丢失0条记录
[调试]: 日志类型'browser'销毁时丢失0条记录

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.08.27 12:18:14