diff --git a/tcpdialer.go b/tcpdialer.go index 8d6bbfb1e5..0023cf60aa 100644 --- a/tcpdialer.go +++ b/tcpdialer.go @@ -327,7 +327,11 @@ func (d *TCPDialer) tryDial(network string, addr *net.TCPAddr, deadline time.Tim defer func() { <-concurrencyCh }() } - dialer := net.Dialer{LocalAddr: d.LocalAddr} + dialer := net.Dialer{} + if d.LocalAddr != nil { + dialer.LocalAddr = d.LocalAddr + } + ctx, cancel_ctx := context.WithDeadline(context.Background(), deadline) defer cancel_ctx() conn, err := dialer.DialContext(ctx, network, addr.String())