Pieterjan Lambein Pieterjan Lambein - 1 year ago 164
HTTP Question

Golang net Dial user:pass@ip:port gives: no such host

I'm trying to connect to a proxy server to start an HTTP CONNECT tunnel. The proxy server uses authentication. This code however fails to work:

conn, err := net.Dial("tcp", "[user:pass@111.222.333.444]:5555")

Even though the host exists, I get an error:

"dial tcp: lookup user:pass@111.222.333.444: no such host"

The string format I'm using was described in this post. Can't seem to get it to work though.

Answer Source

I eventually found the problem. The net.Dial() method wasn't the one concerned with proxy authentication.

I just had to fill in the "Proxy-Authorization" header of the request before calling for am HTTP response. So my TCP address became:

conn, err := net.Dial("tcp", "111.222.333.444:5555")
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download