Skip to content

net/http: http.Get fails with "connection reset by peer" after update to Go 1.23 but works flawlessly up to 1.22.8 #70139

Description

@Roemer

Go version

go version go1.23.2 linux/amd64

Output of go env in your module/workspace:

GO111MODULE=''
GOARCH='amd64'
GOBIN=''
GOCACHE='/root/.cache/go-build'
GOENV='/root/.config/go/env'
GOEXE=''
GOEXPERIMENT=''
GOFLAGS=''
GOHOSTARCH='amd64'
GOHOSTOS='linux'
GOINSECURE=''
GOMODCACHE='/root/go/pkg/mod'
GONOPROXY='*.mycompany.com'
GONOSUMDB='*.mycompany.com'
GOOS='linux'
GOPATH='/root/go'
GOPRIVATE='*.mycompany.com'
GOPROXY='https://repo.mycompany.com/artifactory/api/go/go'
GOROOT='/usr/local/go'
GOSUMDB='sum.golang.org'
GOTMPDIR=''
GOTOOLCHAIN='auto'
GOTOOLDIR='/usr/local/go/pkg/tool/linux_amd64'
GOVCS=''
GOVERSION='go1.23.2'
GODEBUG=''
GOTELEMETRY='local'
GOTELEMETRYDIR='/root/.config/go/telemetry'
GCCGO='gccgo'
GOAMD64='v1'
AR='ar'
CC='gcc'
CXX='g++'
CGO_ENABLED='0'
GOMOD='/builds/dev-containers/dev-container-features/go.mod'
GOWORK=''
CGO_CFLAGS='-O2 -g'
CGO_CPPFLAGS=''
CGO_CXXFLAGS='-O2 -g'
CGO_FFLAGS='-O2 -g'
CGO_LDFLAGS='-O2 -g'
PKG_CONFIG='pkg-config'
GOGCCFLAGS='-fPIC -m64 -fno-caret-diagnostics -Qunused-arguments -Wl,--no-gc-sections -fmessage-length=0 -ffile-prefix-map=/tmp/go-build3761320793=/tmp/go-build -gno-record-gcc-switches'

What did you do?

I have a very simple repro app that just downloads a file via http.get
The code for this is:

package main

import (
	"fmt"
	"io"
	"net/http"
)

const versionsIndexUrl = "https://gitlab.com/api/v4/projects/gitlab-org%2Frelease-cli/packages"

func main() {
	versionFileContent, err := Download(versionsIndexUrl)
	if err != nil {
		panic(err)
	}
	fmt.Printf("Successfully downloaded %d byte(s)\n", len(versionFileContent))
}

func Download(downloadUrl string) ([]byte, error) {
	resp, err := http.Get(downloadUrl)
	if err != nil {
		return nil, err
	}
	defer resp.Body.Close()
	if resp.StatusCode != http.StatusOK {
		return nil, fmt.Errorf("failed to download file '%s'. Status code: %d", downloadUrl, resp.StatusCode)
	}
	bodyBytes, err := io.ReadAll(resp.Body)
	if err != nil {
		return nil, fmt.Errorf("failed to read body: %w", err)
	}
	return bodyBytes, nil
}

This code is compiled and runs in a container in a GitLab pipeline. The http_proxy and https_proxy variables are set as a proxy is needed for the CI to connect to the outside world.

What did you see happen?

The code above works great if the go version in go.mod ist at max 1.22.8. As soon as I set it to 1.23.0 or higher, the download always fails with

panic: Get "https://gitlab.com/api/v4/projects/gitlab-org%2Frelease-cli/packages": read tcp 10.127.1.6:55264-><proxy-address>: read: connection reset by peer

This is 100% reproducible in our environment. 1.22.8 (or lower) always works, starting from 1.23.0 it always fails without changing anything else.

What did you expect to see?

In other environments (also on the lokal workstation with also needs a proxy), this works regardless of the go version but on all GitLab runners, it always fails and I am pretty much at a loss on what I could do more to fix this.

Activity

  1. ianlancetaylor commented on Oct 31, 2024

    @ianlancetaylor
    Contributor

    CC @neild @golang/security

    Thanks for providing a small test case. Unfortunately, I can't recreate the problem. In all cases when I run your program I get

    Successfully downloaded 11438 byte(s)
    

    I've tried with various language versions in go.mod and various compiler versions.

  2. added
    NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.
    on Oct 31, 2024
  3. Roemer commented on Oct 31, 2024

    @Roemer
    Author

    Thanks for your answer. For us, it works on most machines but fails on all 30+ ci agents and I have no more idea what could cause this issue. Is there some way to debug this further?

  4. seankhliao commented on Oct 31, 2024

    @seankhliao
    Member

    I think you need to look at your proxy. It's the one that's terminating the connections.

  5. added
    WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.
    on Oct 31, 2024
  6. FiloSottile commented on Oct 31, 2024

    @FiloSottile
    Contributor

    Try GODEBUG=tlskyber=0 (and in general when debugging a breakage between releases, try switching the updated GODEBUGs one by one). If it fixes it, you have a proxy affected by https://tldr.fail or otherwise incompatible with post-quantum key shares in a non-compliant way.

  7. Roemer commented on Oct 31, 2024

    @Roemer
    Author

    I think you need to look at your proxy. It's the one that's terminating the connections.

    But when I compile with go 1.22.8 (or lower) it works with the same proxy, only when using go 1.23.0 or higher and everything else is exactly the same, it fails.

  8. Roemer commented on Nov 1, 2024

    @Roemer
    Author

    Try GODEBUG=tlskyber=0 (and in general when debugging a breakage between releases, try switching the updated GODEBUGs one by one). If it fixes it, you have a proxy affected by https://tldr.fail or otherwise incompatible with post-quantum key shares in a non-compliant way.

    Thank your for your hint. I now went thru all the GODEBUG Values, my go env (which is used for building and then immediately running the application) shows GODEBUG='httpservecontentkeepheaders=1,x509keypairleaf=0,tls3des=1,jstmpllitinterp=1,x509negativeserial=1,tlskyber=0,winreadlinkvolume=0,winsymlink=0,asynctimerchan=1' but I still get the same error with go 1.23 but not with 1.22. Is there anything else I could try?

  9. Roemer commented on Nov 1, 2024

    @Roemer
    Author

    Nevermind. I set it in the wrong layer (my app runs nested in one more container that was missing the GODEBUG).
    I've added godebug tlskyber=0 to my go.mod and now it works correctly so it is indeed a problem with one of our corporate proxies. Thank you for all the support (and new information about GODEBUG). I'll close this as it is not an issue with Go itself.

  10. FiloSottile commented on Nov 1, 2024

    @FiloSottile
    Contributor

    Glad we could help! If you can share any details about the proxy, sometimes we can backchannel to the vendors, or at least document it for the next person.

  11. Roemer commented on Nov 1, 2024

    @Roemer
    Author

    I'll see if I can get that information and post back here and also in tldr.fail.

  12. Roemer commented on Jan 27, 2025

    @Roemer
    Author

    Sorry for the late reply. But here are the data:
    The software ist Broadcom ProxySG
    The issue was fixed by the vendor with version 7.3.22.1

  13. fanybook commented on Apr 15, 2025

    @fanybook

    I have same problem

    go1.20.3
    go1.22.8
    go1.22.12

    When I attempt to fetch 500 items at once using http.Get(url very long),
    the request succeeds with the http scheme but fails with the https scheme, resulting in a "read: connection reset by peer" error.

    &tls.Config{InsecureSkipVerify: true} invalid
    no this problem in postman
    no this problem when fetch 50 items at once(using http.Get)

  14. locked and limited conversation to collaborators on Apr 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    FrozenDueToAgeNeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.WaitingForInfoIssue is not actionable because of missing required information, which needs to be provided.

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions