Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

net/http: http.Get: connection reset by peer on macOS #23158

Closed
sintanial opened this issue Dec 17, 2017 · 1 comment
Closed

net/http: http.Get: connection reset by peer on macOS #23158

sintanial opened this issue Dec 17, 2017 · 1 comment

Comments

@sintanial
Copy link

What version of Go are you using (go version)?

go version go1.9.2 darwin/amd64

Does this issue reproduce with the latest release?

yes

What operating system and processor architecture are you using (go env)?

GOARCH="amd64"
GOBIN="/Users/roman/go/bin"
GOEXE=""
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
GOPATH="/Users/roman/go"
GORACE=""
GOROOT="/usr/local/go"
GOTOOLDIR="/usr/local/go/pkg/tool/darwin_amd64"
GCCGO="gccgo"
CC="clang"
GOGCCFLAGS="-fPIC -m64 -pthread -fno-caret-diagnostics -Qunused-arguments -fmessage-length=0 -fdebug-prefix-map=/var/folders/dr/8l_15wcn2_bfj47vdvsm4q3w0000gn/T/go-build185245545=/tmp/go-build -gno-record-gcc-switches -fno-common"
CXX="clang++"
CGO_ENABLED="1"
CGO_CFLAGS="-g -O2"
CGO_CPPFLAGS=""
CGO_CXXFLAGS="-g -O2"
CGO_FFLAGS="-g -O2"
CGO_LDFLAGS="-g -O2"
PKG_CONFIG="pkg-config"

What did you do?

It's very simple code :).

I try to http.Get("http://google.com") and receive error: Get http://google.com: read tcp 10.9.58.79:51401->172.217.5.238:80: read: connection reset by peer. Domain is no matter, it's not working for all domains :(

Here is a simple example of code:

package main

import (
	"net/http"
)

func main() {
	http.Get("http://google.com")
}

After several experiments I came to the conclusion that error receives only on http request, on https works fine like this http.Get("https://google.com") and this bug receives only on macOS ! I tried on linux and everything worked as it should. My system is:

System: macOS 10.13.1 (17B1003)
Kernel: Darwin 17.2.0

And by the end of my experiments, I noticed that if I add the User-Agent header (empty or not empty, it's not matter), everything works fine like this:

package main

import (
	"net/http"
	"fmt"
)

func main() {
	req, err := http.NewRequest("GET", "http://google.com/", nil)
	if err != nil {
		panic(err)
	}
	req.Header.Set("User-Agent", "")

	fmt.Println(http.DefaultClient.Do(req))
}

What did you expect to see?

result of request

What did you see instead?

error

@sintanial
Copy link
Author

Sorry, the problem was in my private tunnel vpn, I turned it off and it all worked fine

@golang golang locked and limited conversation to collaborators Dec 17, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants