diff --git a/derp/derphttp/derphttp_client.go b/derp/derphttp/derphttp_client.go index 3c8408e95..c52ee33c7 100644 --- a/derp/derphttp/derphttp_client.go +++ b/derp/derphttp/derphttp_client.go @@ -867,7 +867,15 @@ func (c *Client) dialNodeUsingProxy(ctx context.Context, n *tailcfg.DERPNode, pr } }() - target := net.JoinHostPort(n.HostName, "443") + // Keep port selection in sync with dialNode. + port := "443" + if !c.useHTTPS() { + port = "3340" + } + if n.DERPPort != 0 { + port = fmt.Sprint(n.DERPPort) + } + target := net.JoinHostPort(n.HostName, port) var authHeader string if buildfeatures.HasUseProxy {