Fixing "GOPROXY list is not the empty string, but contains no entries" in Go
What This Error Actually Means
Go resolves modules through GOPROXY, an environment variable that tells the toolchain where to fetch dependencies from. The error message is oddly specific:
GOPROXY list is not the empty string, but contains no entries
This means GOPROXY is set to something, but once Go parses it, there are zero usable proxy URLs in it. Common causes:
- A stray comma or pipe with no actual URL (
GOPROXY=,orGOPROXY=|) GOPROXY=off, which explicitly disables all proxying- A shell-level override with a blank or whitespace value that shadows your real Go config
- A corporate/custom proxy URL that no longer resolves
This is especially common on Windows with Git Bash (MINGW64), where environment variables inherited from Windows user/system settings can silently override what Go has configured in its own env file.
Step-by-Step Fix
Check for a shell-level override
Environment variables set in your current shell session take priority over Go's own config file. Check what's actually there:echo "GOPROXY=[$GOPROXY]"If this prints
GOPROXY=[],GOPROXY=[ ], or something malformed, that's your problem - the shell is passing Go a broken value.Clear the session override
unset GOPROXYThis drops the bad value for the current session and lets Go fall back to its own configuration.
Persist a valid proxy in Go's config
This writes directly to Go's env file (%USERPROFILE%\AppData\Roaming\go\envon Windows,~/.config/go/envon Linux/macOS):go env -w GOPROXY=https://proxy.golang.org,directThe
,directfallback tells Go to bypass the proxy and fetch directly from source control if a module isn't available there - a good safety net. If you're behind a corporate network or VPN, swap in your internal proxy instead:go env -w GOPROXY=https://your-company-proxy.example.com,directSanity-check related settings
go env GOPROXY GOFLAGS GOSUMDBExpected healthy values:
| Variable | Expected value |
|---|---|
|GOPROXY|https://proxy.golang.org,direct(or your internal proxy +,direct) |
|GOFLAGS| Empty, unless you intentionally use flags like-mod=mod|
|GOSUMDB|sum.golang.org(default), unless disabled for a reason |Clear Go's caches if the problem persists
Sometimes a bad proxy state gets baked into cached build artifacts or module downloads. If steps 1-4 didn't fully resolve things, nuke the caches:go clean -cache -testcache -modcache| Flag | Clears |
|---|---|
|-cache| Compiled build cache |
|-testcache| Cached test results |
|-modcache| Downloaded modules ($GOPATH/pkg/mod) |This forces a full re-download of every dependency on your next build, using your now-corrected proxy settings.
Retry
go mod tidy
At this point, all thoseGOPROXY list is not the empty string...lines should be gone, replaced by normal module resolution output fortodo-services.
Windows/MINGW64 Gotcha
If GOPROXY keeps reverting to a bad value in new terminal sessions, the override probably lives in Windows System Properties โ Environment Variables, not just in go env. Go's own persisted config won't help if Windows keeps re-injecting a bad value into every new shell. Check it directly:
cat "$USERPROFILE/AppData/Roaming/go/env"
Quick Reference Checklist
echo "GOPROXY=[$GOPROXY]"- no stray/invalid shell overrideunset GOPROXY- if a bad session override existsgo env -w GOPROXY=https://proxy.golang.org,direct- sets a valid persistent proxygo env GOPROXY GOFLAGS GOSUMDB- confirms sane valuesgo clean -cache -testcache -modcache- if issues persistgo mod tidy- succeeds after the above
Command Cheat Sheet
go version # Confirm installed Go version
go env # Print all Go environment settings
go env GOPROXY # Print a specific setting
go env -w KEY=VALUE # Persist a setting to Go's env file
go env -u KEY # Unset a persisted setting (revert to default)
go mod tidy # Sync go.mod/go.sum with imports
go clean -cache -testcache -modcache # Clear build, test, and module caches
If this saved you a headache, drop a - and if you've hit a different flavor of this error, I'd love to hear about it in the comments.
Top comments (0)
Comments
No comments yet. Start the discussion.