title: Golang http client failing with: dial tcp <some ip>: connect: operation timed out
body: <p>I have a program in Go which takes around 10k urls (<strong>same base url</strong>, simply different resource) and request response for them from 10k goroutines.</p>
  <p>At some point, I start receiving :</p>
  <pre><code>Get &quot;https://.....&quot;: dial tcp &lt;some_ip&gt;: connect: operation timed out
  </code></pre>
  <p>I can't understand whether that's due to some Go limitation, my local machine (macbook) limitation, or the limitations of the Server(s).
  And how can it be solved.</p>
  <p>My code is simple :</p>
  <pre><code>var transport = &amp;http.Transport{
      TLSClientConfig: &amp;tls.Config{InsecureSkipVerify: true},
      Dial: (&amp;net.Dialer{
          Timeout:   0,
          KeepAlive: 0,
      }).Dial,
      TLSHandshakeTimeout: 10 * time.Second,
  }
  var httpClient = &amp;http.Client{Transport: transport}
  
  
  func main() {
     for id := 1; id &lt;= total; id++ {
         myWaitGroup.Add(1)
         go checkUri(myBaseUrl, id, some_chan)
     }
  
     myWaitGroup.Wait()
  }
  
  
  func checkUri(baseUrl string, id int, myChan string) {
      defer myWaitGroup.Done()
  
      url := fmt.Sprintf(`%s/%d.json`, baseUrl, id)
  
      req, _ := http.NewRequest(http.MethodGet, url, nil)
      req.Header.Set(&quot;Content-Type&quot;, &quot;application/json&quot;)
      req.Header.Set(&quot;Connection&quot;, &quot;close&quot;)
      response, err := httpClient.Do(req)
      
      if err != nil {
          fmt.Println(&quot;ERROR: http remote call, err:&quot;, err)
          return
      } else {
          defer response.Body.Close()
          if response.StatusCode != 200 {
              fmt.Printf(&quot;ERROR: remote call status code %d [%s]\n&quot;, response.StatusCode, url)
              return
          } else {
             .. io.ReadAll(response.Body)
             myChan &lt;- fmt.Sprintf(string(b))
             ..
          }
      }
  }
  </code></pre>