Introducing Livops 2.0! Promo codeCEOgives you 8,000 so‘m on your balance.What’s new

go: go.mod requires go >= 1.24 (running go 1.22; GOTOOLCHAIN=local): how to fix it

go: go.mod requires go >= 1.24 (running go 1.22; GOTOOLCHAIN=local) means the go line in go.mod asks for a newer Go than the one running, and GOTOOLCHAIN=local forbids fetching another. Since Go 1.21 the go line is a hard minimum. Build with a Go at least that new, let GOTOOLCHAIN=auto download it, or lower the go line if your code and dependencies allow. toolchain not available means that download failed.

By Livops team, the people who build and run LivopsUpdated

As the go command prints it when the Go you run is older than the go line in go.mod[4] (the versions are examples):

$ go build ./...
go: go.mod requires go >= 1.24 (running go 1.22.12; GOTOOLCHAIN=local)

And the second error people search for, when the go command tried to fetch the newer Go and could not[5][6]:

go: downloading go1.24 (linux/amd64)
go: download go1.24 for linux/amd64: toolchain not available

This page explains the go and toolchain lines in go.mod, what GOTOOLCHAIN decides, why the download fails, and the fixes, from the one that changes the least. The last section shows where it surfaces on Livops.

What does the error mean?

Two lines at the top of go.mod decide which Go may build the module:

module example.com/shop

go 1.24.0

toolchain go1.24.3
  • go is the minimum Go version required to use the module[1][2]. Before Go 1.21 it was advisory only; now it is a mandatory requirement, and a Go toolchain refuses to load a module that declares a newer version than its own[2]. It also sets the language version the compiler enforces for that module’s packages[1].
  • toolchain is a suggested Go toolchain[1]. It cannot be lower than the go line, and it only has an effect when the module is the main module and the Go you run is older than it[2]. With no toolchain line, the go line counts as the suggestion: go 1.21.0 alone reads as toolchain go1.21.0[1].

The go command writes its own name into a toolchain line whenever it updates the go version, usually during go get[2]. That is how a module you last touched with a newer Go on your laptop ends up asking for that Go everywhere else.

So go.mod requires go >= 1.24 (running go 1.22.12 …) reads plainly: the file asks for 1.24, the command running is 1.22.12. The same message with module example.com/[email protected] in place of go.mod means a dependency asks for the newer Go[4], even though your own go line is lower.

What GOTOOLCHAIN decides

Since Go 1.21, the go command can switch to a newer Go on its own. GOTOOLCHAIN controls whether it may[1]:

Value What the go command does when go.mod asks for a newer Go
auto (the default) Runs the newer Go: looks for it in PATH, else downloads it
local Always runs the Go it came with, so it stops with the error
path Looks for the newer Go in PATH only; no download
go1.24.3 Always runs exactly that Go, from PATH or downloaded
go1.24.3+auto Uses go1.24.3 as the starting point, then switches like auto

auto is short for local+auto, and path for local+path[1]. The ; GOTOOLCHAIN=local at the end of the message is printed only when GOTOOLCHAIN is set to something other than auto[4], which tells you the switch was turned off on purpose.

Where that setting comes from, first match wins[1]: the process environment, then your go env -w file, then the go.env file inside the Go installation. The standard Go download ships go.env with GOTOOLCHAIN=auto[8], but repackaged Go toolchains may change this value[1], and with no go.env at all the go command assumes local[1]. A Go from a system package or a container image may therefore behave differently from the one you installed from go.dev. Check what yours uses:

go version
go env GOTOOLCHAIN

With auto, a switch announces itself and the build goes on[1]:

go: module example.com/[email protected] requires go >= 1.24rc1; switching to go 1.27.9

Why the download says toolchain not available

A newer Go is downloaded like any other module, from the module path golang.org/toolchain, through GOPROXY, with its checksum checked against the Go checksum database[1]. toolchain not available means that module does not exist where the go command looked[5]. The usual reasons:

  • An older go command asks for a version that never existed. Since Go 1.21 the first release of a version is 1.N.0: go1.24.0 is a toolchain, go1.24 is not[1]. A go 1.24 line made Go 1.21.0 try to download go1.24 and fail[9]. The go command now adds the .0 itself[5]; that fix is in Go 1.22.4 and not in 1.22.3[10][11], and in Go 1.21.11 and not in 1.21.10[12][13]. If your output says downloading go1.24 without a patch number, this is your case.
  • The go line names a release that is not out. A go line copied from a release candidate or a development build can name a Go that has no released toolchain. Check the release history[3].
  • Downloads are off. With GOPROXY=off, every module lookup counts as not found[7], so the toolchain is reported as not available. With GOSUMDB=off, toolchain downloads fail for lack of verification[1].
  • No network. When the proxy cannot be reached, the message is download go1.24.0: followed by the network error instead[5].

A toolchain line written as toolchain go1.24, or GOTOOLCHAIN=go1.24, fails with invalid toolchain: go1.24 is a language version but not a toolchain version (go1.24.x)[5]. Write the full version.

The fixes, from the smallest change

1. Build with a Go at least as new as the go line

The fix that changes no code. Install the Go that go.mod asks for, or newer, wherever the build runs, and confirm with go version. Go 1.24.0 came out on 11 February 2025[3]. Each major release is supported until two newer ones are out[3], and Go 1.27.4 of 10 November 2026 is the latest[3], so a build server still on Go 1.22, whose last fix came out on 4 February 2025[3], is worth upgrading anyway.

2. Let the go command fetch the newer Go

If the build machine has network access to the module proxy, allow the switch:

GOTOOLCHAIN=auto go build ./...

or set it once for that user:

go env -w GOTOOLCHAIN=auto

To start from a specific Go and still allow later switches, name it: go env -w GOTOOLCHAIN=go1.24.3+auto[1]. The downloaded toolchain is unpacked into the module cache[5], so a build that keeps that cache downloads it once.

This fails offline, behind a proxy that does not serve golang.org/toolchain, or with GOPROXY=off, as shown above. There, fix 1 is the only reliable one. On an older Go 1.21 or 1.22 that asks for go1.24, write the go line with its patch number, go 1.24.0, or upgrade that Go.

3. Lower the go line, only if the code allows it

Lower the version only if nothing needs it. Two things can stop you:

  • the go line must be greater than or equal to the go line of every dependency[2], so a dependency that needs 1.24 keeps you at 1.24;
  • the go line sets the language version the compiler enforces[1], so code that uses newer language features stops compiling.

To try it, let the go command rewrite the file and check the result on the Go you deploy with:

go get [email protected] toolchain@none   # lower the go line, drop the toolchain line
go mod tidy
go build ./... && go test ./...

go get toolchain@none removes the toolchain line[1]. go mod tidy -go=1.22.0 also sets the go line, and adds or removes indirect requirements to match[2].

When a dependency asks for the newer Go

If the message names a module instead of go.mod, that dependency raised its go line in a new version. Either move up the Go you build with (fix 1 or 2), or go back to the last version of that dependency that supports your Go:

go get example.com/[email protected]

How to confirm the fix locally

Run the build with the switch turned off, the way a strict build server does:

GOTOOLCHAIN=local go version
GOTOOLCHAIN=local go build ./...

If both pass, the Go you have is enough for the module and every dependency. To try a given Go without installing it, use a container:

docker run --rm -e GOTOOLCHAIN=local -v "$PWD":/src -w /src golang:1.24 go build ./...

On Livops

  • Where it shows. The deploy stops, and the cabinet shows the error code with the most useful line of the log under it; the full go: line is in the build log. Next to the failed build, the assistant’s button reads the log and explains what happened. See Deploy errors.

  • Which Go builds it. The Livops docs do not name the Go versions the build has. The error tells you: the number after running go is the Go that built your project. Keep the go line at or below it, or choose the Go yourself with a Dockerfile.

  • Choosing the Go version with a Dockerfile. If the repository has a Dockerfile, it is used. In livops.json, "builder": "dockerfile" says so explicitly; like kind, it is read when the project is created. A server app listens on the port in the PORT variable. See Frameworks and livops.json.

    FROM golang:1.24 AS build
    WORKDIR /src
    COPY go.mod go.sum ./
    RUN go mod download
    COPY . .
    RUN CGO_ENABLED=0 go build -o /app .
    
    FROM alpine:3.22
    COPY --from=build /app /app
    CMD ["/app"]
  • A module with no main package stops for another reason; see Build failed.

Building and running a Go web app in production, and what Livops does with a go.mod, is in Go hosting.

Questions

What does the go line in go.mod mean?

It is the minimum Go version needed to use the module. Before Go 1.21 it was advisory; since Go 1.21 a go command refuses to load a module whose go line is newer than itself, and stops with go.mod requires go >= followed by that version.

What is the toolchain line in go.mod?

A suggested Go toolchain for the module, for example toolchain go1.24.0. It cannot be lower than the go line, and it only matters when the module is the main module and the Go you run is older than it. Without it, the go line is taken as the suggestion.

Why does the error say GOTOOLCHAIN=local?

GOTOOLCHAIN=local tells the go command to always use the Go it came with, so it reports the error instead of switching to a newer Go. The standard Go download sets GOTOOLCHAIN=auto in its go.env file, but repackaged Go builds may change that, and the environment or go env -w can override it.

Can I just lower the go line?

Only if nothing needs the newer version. The go line sets the language version the compiler enforces for your code, and it must be at least the go line of every dependency, so lowering it can turn the error into a compile error or a dependency complaint. Test it with go mod tidy and go build on the Go you will deploy with.

What does toolchain not available mean?

The go command tried to download the newer Go as a module from the proxy and the proxy had no such toolchain. Common reasons are a Go 1.21.0 to 1.21.10 or 1.22.0 to 1.22.3 command asking for go1.24 instead of go1.24.0, a go line naming a release that does not exist yet, or GOPROXY=off.

Is Go 1.22 still supported?

No. Each major Go release is supported until two newer major releases are out. Go 1.27.4, released on 10 November 2026, is the latest, so Go 1.26 and 1.27 are the supported lines.

Which Go version does Livops build with?

The Livops docs do not list one. The error itself says it: the number after running go is the Go the build used. To pick the version yourself, build the project with a Dockerfile that starts from the Go image you need.

Sources

  1. Go Docs — Go toolchains (go.dev). Checked .
  2. Go Modules Reference (go.dev). Checked .
  3. Go — Release History (go.dev). Checked .
  4. Go source — cmd/go/internal/gover/toolchain.go (TooNewError) (github.com). Checked .
  5. Go source — cmd/go/internal/toolchain/select.go (github.com). Checked .
  6. Go source — cmd/go/internal/modfetch/fetch.go (github.com). Checked .
  7. Go source — cmd/go/internal/modfetch/proxy.go (github.com). Checked .
  8. Go source — go.env (default settings) (github.com). Checked .
  9. Go issue 62278 — cmd/go: mod tidy reports toolchain not available with 'go 1.21' (github.com). Checked .
  10. Go 1.22.3 source — cmd/go/internal/toolchain/select.go (github.com). Checked .
  11. Go 1.22.4 source — cmd/go/internal/toolchain/select.go (github.com). Checked .
  12. Go 1.21.10 source — cmd/go/internal/toolchain/select.go (github.com). Checked .
  13. Go 1.21.11 source — cmd/go/internal/toolchain/select.go (github.com). Checked .

Put your project online today

Connect GitHub or drop a folder. No card is asked for.

Deploy your Go app

Got a question? — @livops_uz