# GOPROXY, GOPRIVATE and GONOSUMDB: what to set for private modules and a proxy

**CloudRepo Team** November 27, 2026 8 min read

Serving developers since 2016 Founder-run, no venture capital MFA, SSO and audit log on every plan

**Every feature on every plan, with unlimited users.** 14 days free. No credit card required.

[Start free trial](https://www.cloudrepo.io/signup)

Starting at $99/month billed annually.

`GOPRIVATE` is a comma-separated list of glob patterns, in the syntax of Go’s `path.Match`, for module path prefixes that the `go` command should treat as private. It serves as the default value for both `GONOPROXY` and `GONOSUMDB`, telling the `go` command not to connect to a module proxy or to the public checksum database for matching modules. When you want private modules downloaded from version control while everything else uses the default proxy, you do not need to change `GOPROXY`. This guide walks through `GOPROXY`, `GOPRIVATE`, `GONOPROXY`, `GONOSUMDB` and `GOSUMDB`, how the `go` command signs in to a private Go module proxy, and how to save your settings with `go env -w`.

## Read your current settings

Start by checking what the `go` command currently uses. When you pass one or more variable names to `go env`, it prints the value of each named variable on its own line.

**Terminal**

```bash
go env GOPROXY GOPRIVATE GOSUMDB GONOSUMDB
```

By default, `GOPROXY` is `https://proxy.golang.org,direct`, and `GOSUMDB` is `sum.golang.org`, the Go checksum database run by Google. If `GONOSUMDB` is not set, it defaults to `GOPRIVATE`. You can also run `go env GOENV` to print the path to the Go environment configuration file where `go env -w` stores defaults on your machine.

## GOPROXY: where modules come from

`GOPROXY` is a list of module proxy URLs separated by commas (`,`) or pipes (`|`). By default, it is set to `https://proxy.golang.org,direct`.

Two special keywords control downloads in `GOPROXY`:

- `direct` tells the `go` command to download modules directly from version control repositories instead of using a module proxy.
- `off` disallows downloading modules from any source.

The separator after a proxy URL decides when the `go` command moves to the next entry in the list:

- A comma (`,`) tells the `go` command to fall back to the next URL after a `404` or `410` error. All other errors are considered terminal.
- A pipe (`|`) tells the `go` command to fall back to the next source after any error, including non-HTTP errors like timeouts.

With the default `https://proxy.golang.org,direct`, Go tries `https://proxy.golang.org` first and falls back to `direct` if that proxy responds with `404` or `410`. If you want to route downloads through a different module proxy URL, put that URL in `GOPROXY` and pick `,` or `|` for any fallback after it. If you want all modules to come from a single Go module proxy with no fallback, set `GOPROXY` to that proxy URL alone and leave `,direct` off.

## GOPRIVATE, GONOPROXY and GONOSUMDB

`GOPRIVATE`, `GONOPROXY` and `GONOSUMDB` take glob patterns of module path prefixes.

- `GOPRIVATE` is a comma-separated list of glob patterns for module path prefixes that should be considered private. It acts as a default value for `GONOPROXY` and `GONOSUMDB`.
- `GONOPROXY` lists module path prefixes that should not be downloaded from a proxy. For matching modules, the `go` command downloads from the version control repositories where they are developed, regardless of `GOPROXY`. If `GONOPROXY` is not set, it defaults to `GOPRIVATE`.
- `GONOSUMDB` lists module path prefixes that should not be checked using the public checksum database, `sum.golang.org`. If `GONOSUMDB` is not set, it defaults to `GOPRIVATE`.

Because `GOPRIVATE` simply acts as a default for `GONOPROXY` and `GONOSUMDB`, you do not need to set `GONOPROXY` unless `GONOSUMDB` should have a different value.

Go’s [private modules reference](https://go.dev/ref/mod#private-modules) gives these examples.

To download private modules under one prefix from version control while everything else uses the default proxy, set `GOPRIVATE`. The `go` command will not connect to a proxy or to the checksum database for modules starting with `corp.example.com`, and `GOPROXY` does not need to be changed.

```plaintext
GOPRIVATE=corp.example.com
```

To list several private prefixes, separate the glob patterns with commas.

```plaintext
GOPRIVATE=*.corp.example.com,*.research.example.com
```

To use a private proxy that serves your private modules, falling back to the public proxy and then to direct connections, set `GOPROXY` and `GONOSUMDB` instead of `GOPRIVATE`. If `https://proxy.corp.example.com` responds with `404` (Not Found) or `410` (Gone), the `go` command falls back to `https://proxy.golang.org`, then to direct connections to repositories.

```plaintext
GOPROXY=https://proxy.corp.example.com,https://proxy.golang.org,direct
GONOSUMDB=corp.example.com
```

To use a private proxy that serves all modules, list that proxy by itself in `GOPROXY` and set `GONOSUMDB` for your private prefix. That `GOPROXY` setting instructs the `go` command to only download modules from `https://proxy.corp.example.com`, and not to connect to other proxies or version control repositories.

```plaintext
GOPROXY=https://proxy.corp.example.com
GONOSUMDB=corp.example.com
```

You can set these variables in your development environment, such as a `.profile` file, or save them permanently with `go env -w`.

## Leave GOSUMDB on

`GOSUMDB` defaults to `sum.golang.org`, the Go checksum database run by Google. The checksum database cannot compute checksums for non-public modules.

Leave `GOSUMDB` turned on for public modules. If `GOSUMDB` is set to `off`, or if `go get` is invoked with the `-insecure` flag, the checksum database is not consulted and all unrecognized modules are accepted. That gives up the security guarantee of verified repeatable downloads for all modules. A better way to bypass the checksum database for specific modules is to use `GOPRIVATE` or `GONOSUMDB`.

One related variable is `GOINSECURE`, a list of glob patterns of module path prefixes that may be retrieved over HTTP and other insecure protocols. Unlike the `-insecure` flag on `go get`, `GOINSECURE` does not disable module checksum database validation.

## Signing in to a private proxy

The `go` command can authenticate to proxy servers using HTTP basic authentication or request headers supplied by `GOAUTH`. You can specify credentials in a `.netrc` file and optionally choose the file location with the `NETRC` environment variable. If `NETRC` is not set, the `go` command reads `$HOME/.netrc` on UNIX-like platforms or `%USERPROFILE%\_netrc` on Windows.

Keep two rules from Go’s [private modules reference](https://go.dev/ref/mod#private-modules) in mind when setting up `.netrc`:

- The `machine` name cannot be a full URL, so it is not possible to specify different usernames and passwords for different paths on the same machine.
- The `go` command only applies credentials obtained through `GOAUTH`, including its default `.netrc` method, to HTTPS requests.

In Go 1.24 and later, `GOAUTH` may use `.netrc`, run `git credential fill` in a specified working directory, or invoke a custom command. Credentials can also be placed in the `GOPROXY` URL itself, though Go’s reference warns to use caution with that approach because environment variables may appear in shell history and in logs.

## Set it once with go env -w

Instead of setting Go module variables in a `.profile` file, you can save them permanently with `go env -w`. The `-w` flag requires one or more arguments of the form `NAME=VALUE` and changes the default settings of those environment variables.

Defaults changed with `go env -w` are recorded in a Go environment configuration file stored in the per-user configuration directory reported by `os.UserConfigDir`. Running `go env GOENV` prints the effective location of that file.

To clear a default previously set with `go env -w`, pass one or more variable names to `go env -u`.

## Where CloudRepo helps

CloudRepo proxies proxy.golang.org for your Go builds. Set `GOPROXY` to your repository’s URL. Go still checks every public module against sum.golang.org. A CloudRepo [Go proxy](https://www.cloudrepo.io/go) is a cache of `proxy.golang.org`, the Go module mirror, and a Go group is one URL in front of your Go proxies. Go proxy and group repositories are in early access, on every plan. The first time a build requests a module, CloudRepo fetches its `.info`, `.mod` and `.zip` from `proxy.golang.org` and keeps a copy. Your Go proxy and group repositories relay `sum.golang.org`. The `go` command reads every checksum through CloudRepo and checks each one with Go’s own key for `sum.golang.org`. Builds that can reach only CloudRepo still check every public module, and you need no `GONOSUMDB` setting for them (see [Check Go modules through CloudRepo](https://www.cloudrepo.io/docs/consume/go-checksum-database.html)).

Every pull from a Go repository needs a repository token. A missing or wrong token returns 401 Unauthorized.

Add an entry to `~/.netrc` where `login` is the email address of the CloudRepo account that created the repository token and `password` is the token, then run `chmod 600 ~/.netrc` so only you can read the file. In CI, the [Go setup docs for CI](https://www.cloudrepo.io/docs/consume/go.html#in-ci) show how to write the netrc file from a CI secret into a temporary directory and point the `go` command at it with `NETRC`.

`~/.netrc`

```txt
machine your-org.mycloudrepo.io
login you@example.com
password YOUR_REPOSITORY_TOKEN
```

Point `GOPROXY` at your repository with `go env -w`. The URL carries no token, so `go env`, which prints `GOPROXY`, shows none. Do not add `,direct`. With `,direct` added, Go fetches a module CloudRepo does not have from its source host, and CloudRepo never sees that pull. Without it, a module CloudRepo cannot serve fails, and you see why.

**Terminal**

```bash
go env -w GOPROXY=https://your-org.mycloudrepo.io/repositories/your-repo
```

Set `GOPRIVATE` for your own modules, replacing `github.com/acme` with your own prefix (see [Keep your own modules private](https://www.cloudrepo.io/docs/consume/go.html#keep-your-own-modules-private)). Modules under it come straight from your git host using your git credentials, and the `go` command never asks CloudRepo or `sum.golang.org` about them. Without `GOPRIVATE`, the `go` command asks CloudRepo for your private module, CloudRepo asks `proxy.golang.org`, and the module’s path reaches Google, as it does with Go’s own defaults. Set it for your own modules, and only for them.

**Terminal**

```bash
go env -w GOPRIVATE=github.com/acme
```

More: [Private Go module proxy](https://www.cloudrepo.io/go), [Pull Go modules through CloudRepo](https://www.cloudrepo.io/docs/consume/go.html), [Check Go modules through CloudRepo](https://www.cloudrepo.io/docs/consume/go-checksum-database.html), [Repository tokens](https://www.cloudrepo.io/docs/authenticate/repository-tokens.html), [All client guides](https://www.cloudrepo.io/guides).

## Every feature on every plan, with unlimited users

[Start free trial](https://www.cloudrepo.io/signup)

14 days free. No credit card required.

Starting at $99/month billed annually.

![Chris Shellenbarger, founder of CloudRepo](https://www.cloudrepo.io/_astro/chris-headshot-150.DWO5wLdz.jpg)

**Founder-run since 2016, with no venture capital.** A real person answers within one business day. Usually it's me.

Chris, founder of CloudRepo

[Book time with Chris](https://www.cloudrepo.io/meet)

## More guides

- [How to point npm at a private registry with .npmrc 4 min](https://www.cloudrepo.io/guides/npmrc-private-registry)
- [Docker pull-through cache: four ways to set one up 4 min](https://www.cloudrepo.io/guides/docker-pull-through-cache)
- [docker login to a private registry from a laptop, CI and Kubernetes 4 min](https://www.cloudrepo.io/guides/docker-login-private-registry)
- [pip.conf, index-url and extra-index-url: install from a private index safely 4 min](https://www.cloudrepo.io/guides/pip-conf-index-url)
- [Maven settings.xml mirrors: send every build through one repository 4 min](https://www.cloudrepo.io/guides/maven-settings-xml-mirror)
- [nuget.config for a private feed 8 min](https://www.cloudrepo.io/guides/nuget-config-private-feed)
- [The .repo file for dnf, yum and zypper 7 min](https://www.cloudrepo.io/guides/dnf-yum-repo-file)
- [sources.list and signed-by: the current way to add an apt repository 6 min](https://www.cloudrepo.io/guides/apt-sources-list)

---

The page: https://www.cloudrepo.io/guides/goproxy-goprivate
