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

Comments

Projects
None yet
5 participants
@Saurbaum
Copy link

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

This comment has been minimized.

Copy link
Author

commented Oct 16, 2016

Also present on go version go1.7.1 windows/amd64

@minux

This comment has been minimized.

Copy link
Member

commented Oct 16, 2016

@Saurbaum

This comment has been minimized.

Copy link
Author

commented Oct 16, 2016

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 this to the Unplanned milestone Oct 16, 2016

@bradfitz

This comment has been minimized.

Copy link
Member

commented Oct 16, 2016

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

@bradfitz

This comment has been minimized.

Copy link
Member

commented Oct 16, 2016

@Saurbaum

This comment has been minimized.

Copy link
Author

commented Oct 16, 2016

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

@bradfitz

This comment has been minimized.

Copy link
Member

commented Oct 16, 2016

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

This comment has been minimized.

Copy link
Author

commented Oct 16, 2016

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

@Saurbaum Saurbaum closed this Oct 16, 2016

@mikioh

This comment has been minimized.

Copy link
Contributor

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.
You can’t perform that action at this time.