golang/go · error
GOPROXY list is not the empty string, but contains no entrie
Error message
GOPROXY list is not the empty string, but contains no entries
What it means
Proxy configuration error: GOPROXY was a non-empty string but after parsing it yields zero real proxies (or only the implicit 'noproxy' entry injected when GONOPROXY is set). Commonly caused by separators with no URL between them.
Source
Thrown at src/cmd/go/internal/modfetch/proxy.go:122
// Check that newProxyRepo accepts the URL.
// It won't do anything with the path.
if _, err := newProxyRepo(url, "golang.org/x/text"); err != nil {
proxyOnce.err = err
return
}
proxyOnce.list = append(proxyOnce.list, proxySpec{
url: url,
fallBackOnError: fallBackOnError,
})
}
if len(proxyOnce.list) == 0 ||
len(proxyOnce.list) == 1 && proxyOnce.list[0].url == "noproxy" {
// There were no proxies, other than the implicit "noproxy" added when
// GONOPROXY is set. This can happen if GOPROXY is a non-empty string
// like "," or " ".
proxyOnce.err = fmt.Errorf("GOPROXY list is not the empty string, but contains no entries")
}
})
return proxyOnce.list, proxyOnce.err
}
// TryProxies iterates f over each configured proxy (including "noproxy" and
// "direct" if applicable) until f returns no error or until f returns an
// error that is not equivalent to fs.ErrNotExist on a proxy configured
// not to fall back on errors.
//
// TryProxies then returns that final error.
//
// If GOPROXY is set to "off", TryProxies invokes f once with the argument
// "off".
func TryProxies(f func(proxy string) error) error {
proxies, err := proxyList()
if err != nil {View on GitHub (pinned to b6b368adc5)
Solutions
- Set a valid GOPROXY: export GOPROXY=https://proxy.golang.org,direct.
- Strip stray separators and whitespace: echo "$GOPROXY" | tr ',' '\n' | grep -v '^[[:space:]]*$'.
- To genuinely disable proxies, set GOPROXY=direct, not an empty-comma value.
- Audit your Dockerfile / CI matrix and env files for malformed GOPROXY.
Example fix
// before // export GOPROXY=, // after // export GOPROXY=https://proxy.golang.org,direct
Defensive patterns
Strategy: validation
Validate before calling
func validateGOPROXY(s string) error {
s = strings.TrimSpace(s)
if s == "" { return nil }
var n int
for _, e := range strings.Split(s, ",") {
e = strings.TrimSpace(e)
if e == "" { continue }
if e == "direct" || e == "off" || strings.Contains(e, "://") || strings.HasPrefix(e, "file:") { n++ }
}
if n == 0 { return fmt.Errorf("GOPROXY %q has no usable entries", s) }
return nil
} Prevention
- Set GOPROXY explicitly in CI from a known-good template rather than string concatenation.
- To disable proxies use GOPROXY=direct or GOPROXY=off, never empty comma values.
When it happens
Trigger: GOPROXY=",", GOPROXY=" ", or GOPROXY=",," parses to an empty proxy list. The post-parse guard len(proxyOnce.list)==0 fires.
Common situations: Shell quoting mistake when exporting GOPROXY; CI templating that joins an empty proxy list with commas; copy-paste from docs leaving a trailing comma; env file with stray whitespace.
Related errors
- neither GOPATH nor GOMODCACHE are set
- invalid file:// proxy URL with non-path elements: %s
- invalid proxy URL missing scheme: %s
- invalid proxy URL scheme (must be https, http, file): %s
- globalThis.crypto is not available, polyfill required (crypt
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/1558b8913eafd83e.
Report an issue: GitHub.