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: Dial() connection refused error is not syscall.ECONNREFUSED value on windows #45621

Closed
JamesDunne opened this issue Apr 18, 2021 · 2 comments
Closed

Comments

@JamesDunne
Copy link

@JamesDunne JamesDunne commented Apr 18, 2021

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

$ go version
go version go1.16 windows/amd64

Does this issue reproduce with the latest release?

Yes

What did you do?

https://play.golang.org/p/9jvY6yme07T

What did you expect to see?

Expected error value returned from net.Dial() to be a syscall.Errno value equal to syscall.ECONNREFUSED

What did you see instead?

error is a syscall.Errno value: 0x274d
dial tcp [::1]:8080: connectex: No connection could be made because the target machine actively refused it.
@seankhliao seankhliao changed the title windows: net.Dial() connection refused error is not syscall.ECONNREFUSED value net: Dial() connection refused error is not syscall.ECONNREFUSED value on windows Apr 18, 2021
@ianlancetaylor
Copy link
Contributor

@ianlancetaylor ianlancetaylor commented Apr 18, 2021

The exact use of sysca.ECONNREFUSED is inherently system dependent. It doesn't work on all systems. In particular, as you've discovered, it doesn't work on Windows.

What are you really trying to do?

@JamesDunne
Copy link
Author

@JamesDunne JamesDunne commented Apr 19, 2021

Ah very well then.

I'm just trying to suppress otherwise noisy error logging of attempts to connect to a service that is not guaranteed to be up. I worked around the problem on windows by comparing to the exact syscall.Errno value I discovered.

@JamesDunne JamesDunne closed this Apr 19, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
3 participants