Maaz Zindani

Loading the index…

↑↓ move↵ openesc close4791 pages
Node.js, PHP and APIs

go get cannot reach the module mirror and reports connection refused

Your error

Get "https://proxy.golang.org/<module>/@v/list": dial tcp <ip>:443: connect: connection refused2 more lines it can show

Fix it fast

Most common cause, 1 of 3

The network refuses proxy.golang.org, and the comma in GOPROXY blocks the fallback

Skip the mirror and fetch from version control, or keep the mirror but join the list with a pipe, which moves on after any error.

Fix
go env -w GOPROXY=direct
# or keep the mirror and fall back on any error:
go env -w "GOPROXY=https://proxy.golang.org|direct"
# or a company proxy that serves every module:
go env -w GOPROXY=https://proxy.corp.example.com GONOSUMDB=corp.example.com
Did this fix it?
Full steps for this cause: check, fix, verify

Short answer

go get could not connect to proxy.golang.org, the default Go module mirror. The default GOPROXY joins entries with a comma, which falls back to direct only after a 404 or 410, so a refused connection is final. Set GOPROXY to direct, a pipe-joined list or a reachable mirror; repair DNS if the error says lookup. Applies to Go 1.26-1.27.

  • Applies to Go 1.27.4, Go 1.26.11, Linux, macOS and Windows
  • Updated
  • By Maaz Zindani, Senior Software Engineer

Which cause do you have?

Print the three settings that decide where modules and checksums come from, then read the text after the Get URL in your error. "lookup ... on ...:53" means DNS (cause 2), a sum.golang.org URL means the checksum database (cause 3), and "dial tcp <ip>:443" for proxy.golang.org means the mirror itself is unreachable (cause 1).

Run this first
go env GOPROXY GOSUMDB GOPRIVATE

Then find the line you see in this list and open its fix:

  1. 1The network refuses proxy.golang.org, and the comma in GOPROXY blocks the fallbackdial tcp <ip>:443: connect: connection refused for a proxy.golang.org URL, and go env GOPROXY prints https://proxy.golang.org,direct
  2. 2No usable DNS server, so the lookup itself is refusedThe message says lookup proxy.golang.org on [::1]:53 or 127.0.0.1:53, followed by read: connection refused
  3. 3Modules download, but the checksum database sum.golang.org is blockedThe failing URL starts with https://sum.golang.org/lookup/ and the line begins with verifying module:

What does the error look like?

  • Get "https://proxy.golang.org/<module>/@v/list": dial tcp <ip>:443: connect: connection refused
  • Get "https://proxy.golang.org/golang.org/x/tools/gopls/@v/list": dial tcp: lookup proxy.golang.org on [::1]:53: read udp [::1]:49515->[::1]:53: read: connection refused
  • verifying module: golang.org/x/exp@v0.0.0-20200513190911-00229845015e: Get "https://sum.golang.org/lookup/golang.org/x/exp@v0.0.0-20200513190911-00229845015e": dial tcp [::1]:443: connect: connection refused

Cause 1 of 3

The network refuses proxy.golang.org, and the comma in GOPROXY blocks the fallback

You seedial tcp <ip>:443: connect: connection refused for a proxy.golang.org URL, and go env GOPROXY prints https://proxy.golang.org,direct

Check

When go get reports connection refused for proxy.golang.org, something between you and the mirror (a firewall, a hosts-file entry or a network filter) is turning HTTPS away. The Go modules reference explains why direct is never tried: an entry followed by a comma only passes control to the next one after a 404 or 410 reply, and every other error, including a refused connection, is terminal.

Check
curl -sI https://proxy.golang.org | head -1

Fix

Skip the mirror and fetch from version control, or keep the mirror but join the list with a pipe, which moves on after any error. On a company network that runs its own module proxy, list that proxy instead. go env -w stores the choice for future shells.

Fix
go env -w GOPROXY=direct
# or keep the mirror and fall back on any error:
go env -w "GOPROXY=https://proxy.golang.org|direct"
# or a company proxy that serves every module:
go env -w GOPROXY=https://proxy.corp.example.com GONOSUMDB=corp.example.com

Verify

The same go get finishes and go.mod and go.sum gain the new requirement.

Verify
go get example.com/some/module@latest && git diff --stat go.mod go.sum

Confirmed by go.dev

Did this fix it?

Cause 2 of 3

No usable DNS server, so the lookup itself is refused

You seeThe message says lookup proxy.golang.org on [::1]:53 or 127.0.0.1:53, followed by read: connection refused

Check

Here the refused connection belongs to a DNS server, not to the mirror. Go's resolver on Unix reads /etc/resolv.conf, and when the file is missing or lists no nameserver it falls back to 127.0.0.1:53 and [::1]:53. If nothing listens on that port, every module lookup fails before any HTTPS request is made.

Check
cat /etc/resolv.conf

Fix

Give the machine a nameserver that answers: restore the resolver your distribution manages, or write the address of your network's DNS server into /etc/resolv.conf as a nameserver line.

Fix
echo "nameserver <your-dns-server-ip>" | sudo tee /etc/resolv.conf

Verify

The lookup line disappears from the error and the module download starts.

Verify
go mod download -x 2>&1 | head -20

Confirmed by raw.githubusercontent.com

Did this fix it?

Cause 3 of 3

Modules download, but the checksum database sum.golang.org is blocked

You seeThe failing URL starts with https://sum.golang.org/lookup/ and the line begins with verifying module:

Check

After a module arrives, the go command checks its hash against sum.golang.org for anything not yet in go.sum. Only GOPRIVATE, GONOSUMDB or GOSUMDB=off skip that check; switching GOPROXY to direct does not, so a network that blocks Google's services can still fail at the verifying step with connection refused.

Check
go env GOSUMDB GONOSUMDB GOPRIVATE

Fix

Inside mainland China, point GOSUMDB at sum.golang.google.cn, a name the go command already trusts for the same database. For your own private modules, list their prefix in GOPRIVATE so they skip the public database. Avoid GOSUMDB=off: the reference notes it accepts every unrecognised module and gives up verified downloads, and prefers GOPRIVATE or GONOSUMDB for specific paths.

Fix
go env -w GOSUMDB=sum.golang.google.cn
# private modules only:
go env -w GOPRIVATE=corp.example.com

Verify

The download gets past the verifying step and go.sum gains hash lines for the new module.

Verify
go mod download && git diff --stat go.sum

Confirmed by go.dev

Did this fix it?

How do I stop it coming back?

  • Commit go.sum and run go mod download in CI before the build, so network faults show up in their own step.
  • Set GOPROXY, GOSUMDB and GOPRIVATE once per machine with go env -w instead of exporting them in some shells but not others.
  • On restricted networks, run a company module proxy and give every developer the same GOPROXY value.
  • In Dockerfiles, copy go.mod and go.sum and run go mod download in its own layer so a cached layer survives brief outages.

Sources

How was this page made?

I drafted this page with AI assistance from the official documents listed under Sources. Every cause above names the document that confirms it. I have not reproduced this fix on a machine of my own yet, so read it as documented guidance, not a test report. Found a mistake? Tell me.

Which stack is behind this page?

Next step

Want this handled for good?

I look after servers, apps and releases end to end. Tell me what keeps breaking.