golang/go · error
invalid proxy URL missing scheme: %s
Error message
invalid proxy URL missing scheme: %s
What it means
newProxyRepo rejects a proxy URL whose parsed scheme is empty. The go command needs to know which transport to use (http, https, or file), so a bare hostname or path is not acceptable.
Source
Thrown at src/cmd/go/internal/modfetch/proxy.go:211
listLatestErr error
}
func newProxyRepo(baseURL, path string) (Repo, error) {
// Parse the base proxy URL.
base, err := url.Parse(baseURL)
if err != nil {
return nil, err
}
redactedBase := base.Redacted()
switch base.Scheme {
case "http", "https":
// ok
case "file":
if *base != (url.URL{Scheme: base.Scheme, Path: base.Path, RawPath: base.RawPath}) {
return nil, fmt.Errorf("invalid file:// proxy URL with non-path elements: %s", redactedBase)
}
case "":
return nil, fmt.Errorf("invalid proxy URL missing scheme: %s", redactedBase)
default:
return nil, fmt.Errorf("invalid proxy URL scheme (must be https, http, file): %s", redactedBase)
}
// Append the module path to the URL.
url := base
enc, err := module.EscapePath(path)
if err != nil {
return nil, err
}
url.Path = strings.TrimSuffix(base.Path, "/") + "/" + enc
url.RawPath = strings.TrimSuffix(base.RawPath, "/") + "/" + pathEscape(enc)
return &proxyRepo{url, path, redactedBase, sync.Once{}, nil, nil}, nil
}
func (p *proxyRepo) ModulePath() string {
return p.pathView on GitHub (pinned to b6b368adc5)
Solutions
- Prefix the entry with https:// (preferred) or http://.
- For a local directory cache use file:///path.
- Validate every comma-separated GOPROXY entry has an explicit scheme before running go.
Example fix
// before // GOPROXY=proxy.corp.com,direct // after // GOPROXY=https://proxy.corp.com,direct
Defensive patterns
Strategy: validation
Validate before calling
func validateProxyEntry(s string) error {
if s == "direct" || s == "off" { return nil }
u, err := url.Parse(strings.TrimSpace(s))
if err != nil { return err }
if u.Scheme == "" { return fmt.Errorf("proxy URL %q missing scheme", s) }
return nil
} Type guard
func hasProxyScheme(s string) bool {
u, err := url.Parse(strings.TrimSpace(s))
return err == nil && (u.Scheme == "http" || u.Scheme == "https" || u.Scheme == "file")
} Prevention
- Always include https:// (or http://, file://) in every GOPROXY entry.
- Lint GOPROXY in shell startup scripts.
When it happens
Trigger: GOPROXY entry like `proxy.local` or `/cache` with no scheme. url.Parse succeeds but base.Scheme == "".
Common situations: Typing a hostname without https://; templated GOPROXY that drops the scheme; migrating from a config format that omitted schemes.
Related errors
- invalid proxy URL scheme (must be https, http, file): %s
- invalid file:// proxy URL with non-path elements: %s
- git remote (%s) lookup disabled
- git remote (%s) must not be local directory
- GOPROXY list is not the empty string, but contains no entrie
AI-assisted analysis of golang/go@b6b368adc5 (2026-08-12).
Data as JSON: /api/errors/f41952bcd54d4924.
Report an issue: GitHub.