Go "download X: dial tcp: i/o timeout" - Fix in CI
A module download could not establish or finish a connection to the proxy in time. A dial tcp: i/o timeout is a transient network failure that almost always succeeds on retry.
What this error means
A go mod download or build fails with download X: dial tcp 142.250.0.0:443: i/o timeout. Re-running the same job usually works unchanged, the hallmark of a transient issue.
go
go: github.com/foo/bar@v1.0.0: download github.com/foo/bar:
dial tcp 142.250.0.0:443: i/o timeoutCommon causes
Transient proxy or network hiccup
The path between the runner and proxy.golang.org dropped momentarily, timing out the connection.
No module cache between jobs
Every job re-downloads from the network, multiplying exposure to transient timeouts.
How to fix it
Retry the download
- Wrap go mod download in a short bounded retry; transient timeouts usually clear immediately.
.github/workflows/ci.yml
for i in 1 2 3; do go mod download && break; sleep 5; doneCache the module cache
- Cache ~/go/pkg/mod so warm jobs avoid the network entirely.
.github/workflows/ci.yml
- uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: go-mod-${{ hashFiles('**/go.sum') }}How to prevent it
- Cache
~/go/pkg/modkeyed on go.sum. - Add a bounded retry around module downloads.
- Consider a closer module mirror for flaky networks.
Related guides
Go "reading X: 404/410 Not Found" fetching module - Fix in CIFix Go "reading https://proxy.golang.org/...: 404 Not Found / 410 Gone" in CI - a missing version or a transi…
Go "invalid version: unknown revision" - Fix in CIFix Go "invalid version: unknown revision" in CI - the requested module version is not a real tag, commit, or…
Go "toolchain not available" (GOTOOLCHAIN) - Fix in CIFix Go "toolchain X not available" / GOTOOLCHAIN download failures in CI - Go could not obtain the required t…