title: docker login issue - request canceled while waiting for connection
body: <p>All of a sudden docker is showing a strange issue in my system.
  <code>docker login</code> is intermittently failing and <code>docker pull</code> is not working at all :(.</p>
  <p>Here is one instance where the <strong>docker login</strong> was successful but the docker pull failed with an error.</p>
  <pre><code>$ docker login
  Authenticating with existing credentials...
  Login Succeeded
  
  $ docker pull cooldocker19/manas-simple-flask:latest
  Error response from daemon: Head https://registry-1.docker.io/v2/cooldocker19/manas-simple-flask/manifests/latest: Get https://auth.docker.io/token?account=cooldocker19&amp;scope=repository%3Acooldocker19%2Fmanas-simple-flask%3Apull&amp;service=registry.docker.io: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)
  </code></pre>
  <p>When I tried the above url ( ref: <a href="https://auth.docker.io/token?" rel="noreferrer">https://auth.docker.io/token?</a>) from my browser or postman, it returns proper access_token as expected but not sure why docker daemon is not able to get it.</p>
  <p>I followed multiple docker/StackOverflow threads where several people have reported this issue.
  Ex :</p>
  <ul>
  <li><a href="https://github.com/moby/moby/issues/22635#issuecomment-260063252" rel="noreferrer">https://github.com/moby/moby/issues/22635#issuecomment-260063252</a></li>
  <li><a href="https://stackoverflow.com/questions/57269104/client-timeout-exceeded-while-awaiting-headers">Client timeout exceeded while awaiting headers</a></li>
  <li><a href="https://github.com/docker/for-win/issues/1534" rel="noreferrer">https://github.com/docker/for-win/issues/1534</a></li>
  </ul>
  <p><a href="https://i.stack.imgur.com/mb5Oe.png" rel="noreferrer"><img src="https://i.stack.imgur.com/mb5Oe.png" alt="enter image description here" /></a></p>
  <p>I added the following DNS as suggested in several threads but nothing helped. After trying different settings and spending more than 4/5 hours, I am kind of exhausted. Please let me know if you know how to fix this issue.</p>
  <pre><code>{
    &quot;dns&quot;: [
      &quot;8.8.8.8&quot;,
      &quot;8.8.4.4&quot;
    ]
  }
  </code></pre>
  <p>PN - I am able to login to the docker hub from the tray-icon.</p>
  <p><a href="https://i.stack.imgur.com/ECmiN.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ECmiN.png" alt="enter image description here" /></a></p>
  <p><strong>Update 1</strong>
  As per my friend's suggestion, I tried adding the above DNS addressed to my system(Mac) DNS configuration but that didn't help.</p>
  <p>Ref: <a href="https://osxdaily.com/2015/12/05/change-dns-server-settings-mac-os-x/" rel="noreferrer">https://osxdaily.com/2015/12/05/change-dns-server-settings-mac-os-x/</a></p>
  <p><strong>Update 2</strong>
  I tried to troubleshoot with the <strong>dig</strong> and <strong>nslookup</strong>.</p>
  <p>I found that the dig command with the registry-1.docker.io is intermittently(&lt;<strong>20%</strong> time) failing. As mentioned above, there was no significant change in my system in the last few days.</p>
  <p>Not sure if it suggests some issues with that server or my internet(system)!!</p>
  <p>here is the log(lookup failed)</p>
  <pre><code>$ dig @8.8.8.8 registry-1.docker.io
  
  ; &lt;&lt;&gt;&gt; DiG 9.10.6 &lt;&lt;&gt;&gt; @8.8.8.8 registry-1.docker.io
  ; (1 server found)
  ;; global options: +cmd
  ;; connection timed out; no servers could be reached
  </code></pre>
  <p>Ref: <a href="https://www.a2hosting.in/kb/getting-started-guide/internet-and-networking/troubleshooting-dns-with-dig-and-nslookup" rel="noreferrer">https://www.a2hosting.in/kb/getting-started-guide/internet-and-networking/troubleshooting-dns-with-dig-and-nslookup</a></p>