Skip to content

Error: Java setup failed due to network issue or timeout: read ECONNRESET #923

Description

@snago

Description:
Sometimes setup-java fails with Error: Java setup failed due to network issue or timeout: read ECONNRESET
We use distribution: 'corretto' and java-version: '25', but it also happened on earlier Java versions.
The error is rare and seems to vary from day to day, probably ~.1-5%, but for a workflow with 20+ jobs even a 1% error probability means the probability that any of the jobs fail is over 18%.
It would be nice if there was some built-in retries.

Task version:
actions/setup-java@v5
Also happened on actions/setup-java@v4.

Platform:

  • Ubuntu
  • macOS
  • Windows

Runner type:

  • Hosted
  • Self-hosted

Repro steps:
Run setup-java many times (?).

Expected behavior:
No errors.

Actual behavior:
Sometimes fails with ECONNRESET.

Activity

  1. HTHou commented on Sep 22, 2025

    @HTHou

    +1
    Meet the same issue.

  2. v-mahabaleshwars commented on Sep 22, 2025

    @v-mahabaleshwars
    Contributor

    Hi @snago,
    Thank you for creating this issue. We will investigate it and provide feedback as soon as we have some updates.

  3. v-mahabaleshwars commented on Sep 26, 2025

    @v-mahabaleshwars
    Contributor

    Hi snago,

    Thank you for reporting this issue. The ECONNRESET error during Java distribution downloads is indeed frustrating, especially when it compounds across multiple jobs in a workflow. I understand the impact this has on your CI/CD reliability.

    Immediate Workaround – Manual Retry
    While we work on a permanent solution, you can implement a manual retry mechanism in your workflows to significantly reduce the failure rate.

    Reduce Network Calls with Tool Cache
    To further minimize download failures, you can cache the Java installation itself. This avoids repeated downloads from external sources and makes your workflows more resilient to network issues:

    - name: Cache Java Installation
      uses: actions/cache@v4
      with:
        path: |
          ${{ runner.tool_cache }}/Java_Corretto_jdk/25*
          ~/hostedtoolcache/Java_Corretto_jdk/25*
        key: ${{ runner.os }}-java-corretto-25-${{ hashFiles('.github/workflows/*.yml') }}
        restore-keys: |
          ${{ runner.os }}-java-corretto-25-
    
    - name: Setup Java
      uses: actions/setup-java@v5
      with:
        distribution: 'corretto'
        java-version: '25'
    

    Constraints to note:

    • Initial download needed: The first run always downloads Java; caching speeds up only subsequent runs.
    • Runner and OS differences: Cache paths may differ between runner types and operating systems.
    • Workflow changes invalidate cache: Updates to workflow files (e.g., .github/workflows/*.yml) will trigger creation of a new cache.
  4. v-mahabaleshwars commented on Oct 7, 2025

    @v-mahabaleshwars
    Contributor

    Hi @snago, Just wanted to follow up and see if the feedback provided has helped resolve your issue. Let me know if you need any further assistance!

  5. snago commented on Oct 10, 2025

    @snago
    Author

    The "internet weather" has been pretty calm lately. I haven't seen the problem in a while.

    Thanks for the workarounds! Next time it happens I'll try the tool cache approach.
    It adds a lot of clutter to the workflow though, so some retries in setup-java itself would still be an improvement, IMHO.

  6. v-mahabaleshwars commented on Oct 15, 2025

    @v-mahabaleshwars
    Contributor

    Hi @snago,

    Thank you for your patience and feedback on this issue.

    I completely understand your concern about the tool cache approach adding unnecessary complexity to workflows. You're absolutely right that having built-in retry logic in setup-java would provide a much cleaner and more maintainable solution.

    The good news is that we're actively working on implementing a retry mechanism to handle transient network failures like the ECONNRESET errors you experienced. This enhancement will automatically retry failed downloads when temporary connectivity issues occur, eliminating the need for manual workarounds in your workflows.

    Since the immediate issue appears to have been resolved (likely due to improved network conditions between GitHub Actions and the download endpoints), I'll close this issue for now. However, please don't hesitate to reopen this issue if you encounter similar ECONNRESET errors again or create a new issue with any additional details or patterns you observe.

  7. jacobras commented on Oct 24, 2025

    @jacobras

    @mahabaleshwars JFYI: we see this connection issue still occurring a lot. Multiple times a day, taking up to 10 retries.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

bugSomething isn't working

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions