http.Get connection refused

2,878 views
Skip to first unread message

nz

unread,
Sep 11, 2013, 8:26:35 PM9/11/13
to golan...@googlegroups.com
Simple setup, on the same system I do a ..

...~>wget localhost:8000/foo
--2013-09-11 17:18:15--  http://localhost:8000/foo
Resolving localhost... ::1, 127.0.0.1
Connecting to localhost|::1|:8000... connected.
HTTP request sent, awaiting response... 404 File not found
2013-09-11 17:18:15 ERROR 404: File not found.

func main() {
response, err := http.Get("http://localhost:8000/foo")
fmt.Println(response,err);
}
<nil> Get http://localhost:8000/foo: dial tcp 127.0.0.1:8000: connection refused

Should not GO be returning a 404 in the response ? If I change the server to listen on port 80 then the response is as expected (a 404 response object and a nil error) so it almost seems like go is blocked on some ports ?

Nz



Dave Cheney

unread,
Sep 11, 2013, 8:38:51 PM9/11/13
to nz, golang-nuts
Look closely at the difference between wget and your go code. Wget
chose to connect on the ipv6 loopback ::1, Go used 127.0.0.1, the IPv4
loopback.

The question is, why is your test server listening only on ipv6.
> --
> You received this message because you are subscribed to the Google Groups
> "golang-nuts" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to golang-nuts...@googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.

nz

unread,
Sep 11, 2013, 11:23:24 PM9/11/13
to golan...@googlegroups.com, nz
Thanks for spotting that. I followed it back to a configuration setting in the server software and have the issue resolved.

Nz

Dave Cheney

unread,
Sep 11, 2013, 11:28:20 PM9/11/13
to nz, golan...@googlegroups.com, nz
Cool. Glad it was a simple fix. 
Reply all
Reply to author
Forward
0 new messages