Disable HTTP/2 in Go web servers and clients by setting GODEBUG=http2client=0,http2server=0 to prevent timeouts from buggy implementations.
Set the GODEBUG environment variable to http2client=0 or http2server=0 to disable HTTP/2 and prevent timeout errors caused by buggy implementations. This forces the Go HTTP client or server to use HTTP/1.1 exclusively.
export GODEBUG=http2client=0,http2server=0
Alternatively, set the default behavior in your go.mod file for Go 1.23+:
godebug (
http2client=0
http2server=0
)
Go's HTTP client and server automatically try to use the faster HTTP/2 protocol, which can cause timeouts if the other end has a buggy implementation. Setting this debug flag tells Go to skip HTTP/2 and stick to the older, more compatible HTTP/1.1 protocol. It is like telling a driver to avoid a new highway shortcut that is currently under construction and just take the old, reliable road instead.