16

Since yesterday out of nowhere I'm not able to pull images anymore. And I can't login into docker with docker login. The same error appears:

Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)

I'm not behind any proxy and all of my docker container itself work well. I'm running it at home and the only reverse proxy I use is running in a container and can't be the reason.

Running on:

  • Ubuntu 18.04.4 LTS
  • Docker version 19.03.5, build 633a0ea
Promise Preston
  • 24,334
  • 12
  • 145
  • 143
CptDayDreamer
  • 1,526
  • 6
  • 25
  • 61

7 Answers7

39

This helped me:

sudo nano /etc/resolv.conf

Set the nameserver to 8.8.8.8.

Restart the docker demon.

sudo systemctl restart docker
Dmitry Krivolap
  • 1,354
  • 9
  • 16
  • 1
    what is this doing? can this break something? is there a security vulnerability linked to this ? – Robycool Mar 03 '21 at 11:31
  • 1
    This worked for me. This simply changes the DNS to Google's public DNS. And yes it is safe as long as you choose a well-known DNS server such as Google's 8.8. 8.8. – Promise Preston Mar 22 '21 at 13:18
  • 8.8.8.8 is removed from my PC each time my system restarts, is there a way to make it permanent? – imharjyotbagga Dec 26 '21 at 11:38
6

Try to update /etc/resolv.conf

nameserver 8.8.8.8
nameserver 8.8.4.4
Theo
  • 79
  • 3
  • What is the first nameserver? And I already tried both of the google nameserver and that didn't changed anything. – CptDayDreamer Mar 20 '20 at 00:42
  • This was an entry from my file, sorry :( – Theo Mar 20 '20 at 00:44
  • No problem bro but like I said that's not working. I found an solution but I think this won't work forever: https://forums.docker.com/t/docker-pull-results-in-request-canceled-while-waiting-for-connection-client-timeout-exceeded-while-awaiting-headers/73064/16 the solution of franelas – CptDayDreamer Mar 20 '20 at 00:59
  • 8.8.8.8 is removed from my PC each time my system restarts, is there a way to make it permanent? – imharjyotbagga Dec 26 '21 at 11:38
4

I added nameserver 8.8.8.8 in all my worker nodes and the issue was resolved

3

This usually happens when you are behind the proxy OR on a corporate network. Though you export proxy locally on a shell docker doesn't understand that. So the workaround would be -

Create a file if not present - /etc/systemd/system/docker.service.d/http-proxy.conf

#Add proxy server details as below -

[Service]

Environment="HTTP_PROXY=http://proxy.example.com:port/" Environment="HTTPS_PROXY=https://proxy.example.com:port/"

(Notice the trailing '/' which is very important)

systemctl daemon-reload

systemctl restart docker

user316935
  • 31
  • 2
2

In my case, it gets resolved after configuring the proxy. I am using Windows Docker (Refer 'Proxy Configuration' section from here for more details)

Naren Chejara
  • 1,124
  • 10
  • 7
  • Yes, In my case too. If you are in VPC and if certain resources opened through only proxy in such cases may be... For future visitors.. Try the docker proxy (You may need to use your company provided proxy and refer below link to know how to apply) https://docs.docker.com/config/daemon/systemd/ – PraveenKumar Lalasangi Jan 26 '22 at 10:24
0

I had a similar issue when I upgraded to using Cloudflare. What solved this issue for me was:

  • navigate to your DNS record either in Cloudflare or google cloud,
  • delete the DNS record for docker and nexus if you have that,
  • then the DNS record should be automatically recreated,

and voila the issue is resolved.

AlM
  • 21
  • 2
0

I ran into this once as well from a different source: A docker script was trying to use a private docker image and repo and once I used a public image for that container everything worked perfectly. I was then able to figure out the right permissions and resolved the error as well.

Higgs Bogson
  • 361
  • 2
  • 5