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

使用Angular CLI执行ng e2e时遇connect ETIMEDOUT错误求助

Fixing Angular CLI ng e2e "connect ETIMEDOUT" Error

Hey there, let's work through this ng e2e timeout issue you're hitting. I've dealt with similar problems when running end-to-end tests with Angular CLI, so here are several practical fixes that should get your tests running smoothly:

  • Verify ChromeDriver and Chrome version compatibility
    Protractor (which ng e2e uses under the hood) relies on ChromeDriver, and version mismatches between Chrome and ChromeDriver are a common cause of connection timeouts. First, check your Chrome browser version (go to chrome://settings/help), then:

    • Install the matching ChromeDriver version via npm:
      npm install chromedriver@<your-chrome-version> --save-dev
    • Or update webdriver-manager to use the correct version:
      webdriver-manager update --versions.chrome=<your-chrome-version>
  • Adjust timeout settings in Protractor config
    The default timeout values might be too short for your environment. Open protractor.conf.js in your project root and increase these two settings:

    exports.config = {
      // ... existing config
      allScriptsTimeout: 30000, // Increase from default 11000
      jasmineNodeOpts: {
        showColors: true,
        defaultTimeoutInterval: 30000, // Extend this as well
        // ... other Jasmine options
      }
    };
    
  • Manually start the dev server before running e2e tests
    Sometimes ng e2e tries to run tests before the local development server is fully ready. Try this two-step approach:

    1. In one terminal, start the server: ng serve
    2. In another terminal, run e2e tests without starting a new server: ng e2e --serve=false
  • Check for proxy or firewall interference
    If you're on a network with a proxy or firewall, it might be blocking Protractor's connection to the local dev server. Try temporarily disabling your firewall/proxy to rule this out. If that fixes it, you can add proxy settings to your protractor.conf.js using the proxy option under capabilities.

  • Clean dependencies and webdriver cache
    Corrupted dependencies or webdriver cache can cause odd issues. Run these commands to reset everything:

    rm -rf node_modules package-lock.json
    npm install
    webdriver-manager clean
    webdriver-manager update
    

Give these steps a try one by one—most likely one of them will resolve the timeout error.

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.25 06:14:03