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: Error fetching URL: Get "http://www.google.com": proxyconnect tcp: dial tcp: lookup http: no such host #61436

Closed
yangjing1981 opened this issue Jul 19, 2023 · 2 comments

Comments

@yangjing1981
Copy link

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

$ go version go1.18.10 windows/amd64

Does this issue reproduce with the latest release?

No

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

go env Output
$ go env
C:\Users\Administrator>go env
set GO111MODULE=on
set GOARCH=amd64
set GOBIN=
set GOCACHE=C:\Users\Administrator\AppData\Local\go-build
set GOENV=C:\Users\Administrator\AppData\Roaming\go\env
set GOEXE=.exe
set GOEXPERIMENT=
set GOFLAGS=
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOINSECURE=
set GOMODCACHE=C:\Users\Administrator\go\pkg\mod
set GONOPROXY=
set GONOSUMDB=
set GOOS=windows
set GOPATH=C:\Users\Administrator\go
set GOPRIVATE=
set GOPROXY=https://goproxy.cn,direct
set GOROOT=C:\Program Files\Go
set GOSUMDB=sum.golang.google.cn
set GOTMPDIR=
set GOTOOLDIR=C:\Program Files\Go\pkg\tool\windows_amd64
set GOVCS=
set GOVERSION=go1.18.10
set GCCGO=gccgo
set GOAMD64=v1
set AR=ar
set CC=gcc
set CXX=g++
set CGO_ENABLED=1
set GOMOD=NUL
set GOWORK=
set CGO_CFLAGS=-g -O2
set CGO_CPPFLAGS=
set CGO_CXXFLAGS=-g -O2
set CGO_FFLAGS=-g -O2
set CGO_LDFLAGS=-g -O2
set PKG_CONFIG=pkg-config
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0 -fdebug-prefix-map=C:\Users\ADMINI~1\AppData\Local\Temp\go-build205457987=/tmp/go-build -gno-record-gcc-switches

What did you do?

code Output

package main

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

func main() {
//url := "https://www.google.com" //ok
url := "http://www.google.com" //failed

// Retry for a maximum of 3 times with a 1-second delay between retries
maxRetries := 3
retryDelay := time.Second

for i := 0; i < maxRetries; i++ {
	resp, err := http.Get(url)
	if err == nil {
		// Successfully fetched the URL, handle the response here
		fmt.Println(resp.Status)
		resp.Body.Close()
		break
	}

	// If there's an error, wait before retrying
	fmt.Printf("Error fetching URL: %s. Retrying...\n", err)
	time.Sleep(retryDelay)
}

fmt.Println("Finished.")

}

What did you expect to see?

Both http or https can work ok
url := "https://www.google.com" //ok
url := "http://www.google.com" //ok

What did you see instead?

url := "https://www.google.com"    //ok
url := "http://www.google.com"     //failed

https

200 OK
Finished.

http

Error fetching URL: Get "http://www.google.com": proxyconnect tcp: dial tcp: lookup http: no such host. Retrying...
Finished.
@yangjing1981
Copy link
Author

Linux can work fine for both http and https.

@seankhliao
Copy link
Member

We no longer support 1.18.
Note that this looks like a misconfiguration of any http proxies you may have configured in your environment.

Unlike many projects, the Go project does not use GitHub Issues for general discussion or asking questions. GitHub Issues are used for tracking bugs and proposals only.

For questions please refer to https://github.com/golang/go/wiki/Questions

@seankhliao seankhliao closed this as not planned Won't fix, can't repro, duplicate, stale Jul 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants