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 showFix it fast
Most common cause, 1 of 3The 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.
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.comShort 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.
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).
go env GOPROXY GOSUMDB GOPRIVATEThen find the line you see in this list and open its fix:
- 1The network refuses proxy.golang.org, and the comma in GOPROXY blocks the fallback
dial tcp <ip>:443: connect: connection refused for a proxy.golang.org URL, and go env GOPROXY prints https://proxy.golang.org,direct - 2No usable DNS server, so the lookup itself is refused
The message says lookup proxy.golang.org on [::1]:53 or 127.0.0.1:53, followed by read: connection refused - 3Modules download, but the checksum database sum.golang.org is blocked
The 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 refusedGet "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 refusedverifying 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.
curl -sI https://proxy.golang.org | head -1Fix
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.
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.comVerify
The same go get finishes and go.mod and go.sum gain the new requirement.
go get example.com/some/module@latest && git diff --stat go.mod go.sumConfirmed by go.dev
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.
cat /etc/resolv.confFix
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.
echo "nameserver <your-dns-server-ip>" | sudo tee /etc/resolv.confVerify
The lookup line disappears from the error and the module download starts.
go mod download -x 2>&1 | head -20Confirmed by raw.githubusercontent.com
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.
go env GOSUMDB GONOSUMDB GOPRIVATEFix
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.
go env -w GOSUMDB=sum.golang.google.cn
# private modules only:
go env -w GOPRIVATE=corp.example.comVerify
The download gets past the verifying step and go.sum gains hash lines for the new module.
go mod download && git diff --stat go.sumConfirmed by go.dev
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.