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
gois 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].toolchainis a suggested Go toolchain[1]. It cannot be lower than thegoline, and it only has an effect when the module is the main module and the Go you run is older than it[2]. With notoolchainline, thegoline counts as the suggestion:go 1.21.0alone reads astoolchain 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.0is a toolchain,go1.24is not[1]. Ago 1.24line made Go 1.21.0 try to downloadgo1.24and fail[9]. The go command now adds the.0itself[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 saysdownloading go1.24without a patch number, this is your case. - The go line names a release that is not out. A
goline 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. WithGOSUMDB=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
goline must be greater than or equal to thegoline of every dependency[2], so a dependency that needs 1.24 keeps you at 1.24; - the
goline 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 gois the Go that built your project. Keep thegoline 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. Inlivops.json,"builder": "dockerfile"says so explicitly; likekind, it is read when the project is created. A server app listens on the port in thePORTvariable. 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
- Go Docs — Go toolchains (go.dev). Checked .
- Go Modules Reference (go.dev). Checked .
- Go — Release History (go.dev). Checked .
- Go source — cmd/go/internal/gover/toolchain.go (TooNewError) (github.com). Checked .
- Go source — cmd/go/internal/toolchain/select.go (github.com). Checked .
- Go source — cmd/go/internal/modfetch/fetch.go (github.com). Checked .
- Go source — cmd/go/internal/modfetch/proxy.go (github.com). Checked .
- Go source — go.env (default settings) (github.com). Checked .
- Go issue 62278 — cmd/go: mod tidy reports toolchain not available with 'go 1.21' (github.com). Checked .
- Go 1.22.3 source — cmd/go/internal/toolchain/select.go (github.com). Checked .
- Go 1.22.4 source — cmd/go/internal/toolchain/select.go (github.com). Checked .
- Go 1.21.10 source — cmd/go/internal/toolchain/select.go (github.com). Checked .
- 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 appRelated
- Golang hosting in 2026: how to deploy a Go appGolang hosting means running one compiled binary: build it with CGO off, listen on the PORT the host gives you, and stop cleanly on SIGTERM. Any host that runs a Linux process or a container will do. Koyeb and Fly.io have the lowest always-on dollar prices, Google Cloud Run and Render have free tiers, and a VPS is cheapest when you run many services. On Livops you push a repository with go.mod and it runs as a web app for 39 credits a month, on servers in Uzbekistan. Below: what Go needs, a deploy checklist, and the options with their own prices.
- Docker hosting: how to deploy a Docker container or a DockerfileTo host a container you need a host that builds or pulls the image, starts its CMD, sends traffic to the port it listens on and stops it with SIGTERM. On Livops a Dockerfile at the root of the repository is built on Livops's servers and runs for 39 credits a month (39,000 so'm); a public image from Docker Hub, GHCR or Quay runs without a build. Here is what a container needs, and how a VPS, Render, Railway, Fly.io, DigitalOcean and Heroku compare.
- exec format error in Docker: the image was built for another CPUThe kernel refused to run the container's program because it is not an executable for this machine: almost always a binary or image built for arm64 (an Apple Silicon Mac) running on an amd64 server, or the reverse. Build for the server's platform with --platform linux/amd64, or as a multi-platform image; if the file is a script, give it a #! line.
- App not listening on $PORT: why the health check failed after deployThe platform started your app, tried the port it gave it, and nothing answered in time. Almost always the app listens on its own fixed port instead of the PORT variable, listens on localhost (127.0.0.1) instead of 0.0.0.0, or crashed or was still starting when the check gave up. Listen on 0.0.0.0 and the port in PORT, and it passes.
- Binary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires cgo to work. This is a stub: how to fix itBinary was compiled with 'CGO_ENABLED=0', go-sqlite3 requires cgo to work. This is a stub means the program was built without cgo, so mattn/go-sqlite3 compiled its placeholder driver, which fails on every connection. Build with CGO_ENABLED=1 and a C compiler such as gcc, or switch to a pure-Go SQLite driver like modernc.org/sqlite, registered as sqlite rather than sqlite3, which builds with cgo off.
- java.lang.UnsupportedClassVersionError: has been compiled by a more recent version of the Java Runtime (class file version 65.0): how to fix itjava.lang.UnsupportedClassVersionError: ... has been compiled by a more recent version of the Java Runtime (class file version 65.0), this version of the Java Runtime only recognizes class file versions up to 61.0 means the class was compiled for Java 21 and is being run on Java 17. Run it on a Java at least as new as the one it was built for, or compile for the older release with --release, Maven's maven.compiler.release or a Gradle toolchain.