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: Listen on ":80" does not serve from the machines IP address on windows #17467

Closed
Saurbaum opened this issue Oct 16, 2016 · 9 comments
Closed
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows
Milestone

Comments

@Saurbaum
Copy link

Saurbaum commented Oct 16, 2016

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

go1.6.2 windows/amd64

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

set GOARCH=amd64
set GOBIN=
set GOEXE=.exe
set GOHOSTARCH=amd64
set GOHOSTOS=windows
set GOOS=windows
set GOPATH=C:\Users\ian_n\Documents\Go
set GORACE=
set GOROOT=C:\Go
set GOTOOLDIR=C:\Go\pkg\tool\windows_amd64
set GO15VENDOREXPERIMENT=1
set CC=gcc
set GOGCCFLAGS=-m64 -mthreads -fmessage-length=0
set CXX=g++
set CGO_ENABLED=1

What did you do?

On windows
mux := http.NewServeMux()
mux.HandleFunc("/ping", ping)

http.ListenAndServe(":80", mux)

What did you expect to see?

I would expect to be able to browse to http://localhost/ping and http://{ip address}/ping

What did you see instead?

Only the url using localhost worked.

Using a different port such as 8080 both urls work.
Using linux and port 80 both urls work.

@Saurbaum
Copy link
Author

Also present on go version go1.7.1 windows/amd64

@minux
Copy link
Member

minux commented Oct 16, 2016 via email

@Saurbaum
Copy link
Author

I have specifically allowed it in the firewall even though I am testing on the same physical machine. It makes no difference.

I can see no specific mention of it in my antivirus settings and would have no reason to suspect that as it will serve it up via the normal machine ip address but only if I specify it fully.

i.e.

http.ListenAndServe(":80", mux) only works on local host
http.ListenAndServe("192.168.1.83:80", mux) works but only for the specified ip address
http.ListenAndServe(":8080", mux) works as documented for any connection.

@bradfitz bradfitz changed the title ListenAndServer using ":80" does not serve from the machines IP address on windows. net: Listen on ":80" does not serve from the machines IP address on windows Oct 16, 2016
@bradfitz bradfitz added OS-Windows NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. labels Oct 16, 2016
@bradfitz bradfitz added this to the Unplanned milestone Oct 16, 2016
@bradfitz
Copy link
Contributor

Um, is http:///ping even a valid URL for the http scheme? What does HTTP with no authority mean?

@bradfitz
Copy link
Contributor

/cc @mikioh @alexbrainman

@Saurbaum
Copy link
Author

it seems that it has been edited out because I accidentally used formatting codes. Updated with more clarity.

@bradfitz
Copy link
Contributor

If you say this works fine for port 8080 on your machine, but not port 80, then it sounds like something on your machine (firewall, anti-virus, as @minux suggested) is messing with you.

I'm pretty sure we already have unit tests for exactly this behavior, but if somebody wants to trybot a unit test in the net package listening on ":0" and then looking up the machine's IP addresses and connecting to all interface IP's on that port, and then us running the trybots, that would be interesting. (or we could even submit the test)

/cc @odeke-em who might be interested.

@Saurbaum
Copy link
Author

Ok you've won I'll give up and blame the firewall/antivirus and just use a different port.

@mikioh
Copy link
Contributor

mikioh commented Oct 16, 2016

Have you already tried to run "netstat -oan" before running your application?

I'm not a Windows user and have no Windows box, but when googling "windows+listen+port+80", I can see many articles such as "port 80 is used by system process." Seems like golang-nats or Stack Overflow is the best place for asking questions.

@golang golang locked and limited conversation to collaborators Jul 15, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. OS-Windows
Projects
None yet
Development

No branches or pull requests

5 participants