Docker pull results in "Request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)"

Previous solution only worked until I reboot my machine. Sigh.

But I’ve found another trick in my linux.

I did force the daemon to run through a proxy before connecting the the docker servers, as the registry-1.docker.io was giving me timeout error and I could not even ping it anymore.

Following this instructions I could fix my problem. And that’s all I did:

1. Create a new directory:

$ sudo mkdir -p /etc/systemd/system/docker.service.d

2. Get a free http proxy from this list.

3. Create the file below and paste the http proxy server

# File: /etc/systemd/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=208.123.76.34:8080"
Environment="NO_PROXY=localhost,127.0.0.1"

4. Reload systemd manager configurations:

sudo systemd daemon-reload

5. Restart the Docker’s daemon service:

sudo systemd restart docker

6. Check if it’s working:

docker pull alpine

Now it is working here, but the download speed is slow as it is not connected directly to the server. I googled a lot and I’ve no clue how to fix this another way.

.
Edit: Don’t use a proxy to log in as the connection goes through someone’s pc, they will receive your credentials. Today I removed the http proxy to login, and sometimes the connection is stablished, sometimes it isn’t. My network is slow since the past week. Perhaps that’s the reason?

1 Like