Docker pull: request canceled while waiting for connection
The daemon, not the CLI, timed out reaching the registry. Set proxy in the daemon unit, lower MTU on VPN links, and check DNS inside a container.

Introduction & Quick Summary
A pull never gets an HTTP response back:
docker: 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).The request was made by the daemon, not by the CLI. Something between that daemon and the registry — a proxy that was never configured, an MTU that silently drops large packets, a DNS resolver that stalls, a firewall that accepts the SYN and then black-holes the TLS handshake — consumed the timeout budget before a single response header arrived.
Quick answer, in the order worth trying:
# 1. is it the daemon's egress at all?
docker run --rm curlimages/curl:latest -sS -m 15 -o /dev/null -w '%{http_code}\n' \
https://registry-1.docker.io/v2/
# 2. proxy for the daemon, not your shell
sudo systemctl edit docker
# [Service]
# Environment="HTTPS_PROXY=http://proxy.corp:3128"
# Environment="NO_PROXY=localhost,127.0.0.1,.internal"
sudo systemctl restart docker
# 3. MTU, the usual culprit on VPN and PPPoE links
sudo tee /etc/docker/daemon.json <<'EOF'
{ "mtu": 1400 }
EOF
sudo systemctl restart dockerDo not waste a pull on each attempt: use docker pull against a small image (or curl from a container in the same network namespace) so you learn which of the three layers is broken.
Core Mechanics, Signatures & Reproducible Setup
docker pull is a client request to the daemon, and the daemon then makes three outbound connections: DNS to resolve the registry, TCP to the registry endpoint, then TLS with SNI. net/http: request canceled while waiting for connection specifically means the dial or the TLS handshake never completed — the client-cancel branch of Go's HTTP transport, which fires when the configured timeout expires with no response headers.
The daemon's network settings, and where they live:
| Setting | File | Applies to |
|---|---|---|
| proxy | systemd unit environment or ~/.docker/config.json proxies | pulls, builds, pushes |
| MTU | /etc/docker/daemon.json mtu | container and bridge traffic |
| DNS | host /etc/resolv.conf or daemon.json dns | container resolution |
| registry mirrors | daemon.json registry-mirrors | pull routing |
| insecure registries | daemon.json insecure-registries | plain-HTTP registries only |
Reproduce the timeout deterministically without a real network fault by pointing at an address that drops packets:
docker run --rm alpine sh -c 'nc -w 3 -z 10.255.255.1 443; echo "exit=$?"'
# exit=1 after the timeout: a black-holed SYN looks exactly like a registry timeout
# and the working case, for comparison
docker run --rm alpine sh -c 'nc -w 3 -z 1.1.1.1 443; echo "exit=$?"'
# exit=0Docker Desktop on macOS and Windows runs the daemon inside a VM, so proxy variables set in the host shell reach the CLI but not the daemon. That single asymmetry explains a large share of reports where curl works and docker pull does not.
Key Comparison Table
The message names a layer. Reading it correctly halves the work:
| Message fragment | Layer | First check |
|---|---|---|
Client.Timeout exceeded while awaiting headers | dial or TLS handshake | proxy, MTU, firewall |
TLS handshake timeout | TLS handshake | TLS-inspecting proxy, clock |
dial tcp: i/o timeout | TCP connect | route, MTU, security group |
no such host | DNS | resolver, search domains, VPN |
connection reset by peer | middlebox | MTU black hole, IDS |
toomanyrequests / 429 | registry rate limit | pull limits, mirror, auth |
x509: certificate signed by unknown authority | trust store | corporate CA in the daemon |
Where the setting has to be configured for each environment:
| Environment | Proxy location | Restart needed |
|---|---|---|
| Linux + systemd | systemctl edit docker drop-in | yes |
| Docker Desktop | Settings, Resources, Proxies | yes |
| rootless Docker | ~/.config/systemd/user/docker.service.d | systemctl --user |
| GitLab or GitHub runner | container env on the job | no, if set before start |
| Podman | ~/.config/containers/containers.conf | no |
MTU by link type, since this is the least obvious cause:
| Link | Typical MTU | Symptom |
|---|---|---|
| Ethernet | 1500 | none |
| PPPoE | 1492 | pulls hang after the first packet |
| WireGuard / OpenVPN | 1420 / 1400 | TLS handshake stalls |
| IPsec / GRE | 1400 or less | small requests work, large blobs stall |
| Cloud overlay (VXLAN) | 1450 | intermittent timeouts |
Practical Edge Cases, Error Fixes & Deep Dive Code Examples
1. Prove the MTU theory before changing it
# largest packet that survives without fragmentation
ping -M do -s 1472 -c 1 registry-1.docker.io
# 1472 + 28 bytes of headers = 1500; reduce 1472 until it passes, then add 28
sudo ip link set dev docker0 mtu 1400
docker run --rm alpine ip link show eth0 | head -1If lowering the interface MTU makes the pull work, persist it in daemon.json; an ip link change does not survive a reboot and does not apply to networks created after it.
2. Daemon proxy with the right exclusions
# /etc/systemd/system/docker.service.d/http-proxy.conf
[Service]
Environment="HTTP_PROXY=http://proxy.corp:3128"
Environment="HTTPS_PROXY=http://proxy.corp:3128"
Environment="NO_PROXY=localhost,127.0.0.1,::1,.internal,registry.local"NO_PROXY must contain the registry hostnames, not their IPs, because the proxy decision happens before resolution. A missing NO_PROXY for an internal registry sends internal pulls through a proxy that cannot route them, which appears as the same timeout.
3. Registry mirrors when the upstream is slow
{
"registry-mirrors": ["https://mirror.internal"],
"mtu": 1400
}A mirror answers the manifest request locally and falls back upstream on a miss. docker info shows the configured mirrors and whether they are reachable; a mirror that is itself unreachable makes pulls slower than no mirror at all, so remove dead entries.
4. DNS inside containers is not the host resolver
docker run --rm alpine cat /etc/resolv.conf
# nameserver 127.0.0.11 (embedded DNS on user-defined networks)
docker run --rm --network host alpine cat /etc/resolv.conf
# the host's nameserversOn the default bridge, the embedded resolver forwards to the host's nameservers and caches negative answers for a short period. A VPN that reconnects leaves the daemon holding a stale upstream, and resolution stalls until the cache expires — the fix is a daemon restart, or explicit dns entries in daemon.json.
5. Builds fail where pulls succeed
BuildKit runs build steps in containers with their own network namespace, so a proxy set for the daemon but not passed as a build argument is invisible inside RUN:
docker build \
--build-arg HTTP_PROXY=http://proxy.corp:3128 \
--build-arg HTTPS_PROXY=http://proxy.corp:3128 \
--network=host \
-t app .--network=host is a diagnostic shortcut, not a fix for CI: it makes the build see the host's network but breaks reproducibility. Configure the build arguments and keep the default network.
6. Distinguish a timeout from a rate limit
docker pull alpine:3.21
# toomanyrequests: You have reached your pull rate limit.
# versus
# net/http: request canceled ... Client.Timeout exceededA rate limit returns an HTTP status in seconds and mentions the limit; a timeout has no status at all. Authenticating (docker login) raises the anonymous pull limit and also changes the request path, which occasionally makes a broken proxy configuration reveal itself.
Common Compilation/Runtime Mistakes & Version Gotchas
Setting HTTP_PROXY in the shell and expecting it to affect pulls. The CLI reads it; the daemon does not inherit your interactive environment. Every systemd-managed daemon needs a drop-in, and Docker Desktop needs its own settings screen.
Pointing the proxy at 127.0.0.1. Inside a container or a VM, loopback is not the host. Use the host's bridge address (host.docker.internal, or the gateway IP) and make sure the proxy listens on it.
Raising timeouts instead of fixing the MTU. A longer timeout turns a fast failure into a slow one. The transfer still stalls at the same packet size.
Version differences. Docker 23 switched the default image store to containerd, which changes how pulls are recorded and makes some cache-related errors appear under new names. BuildKit has been the default builder since 23 and uses the daemon's proxy settings only when they are in daemon.json or passed as build arguments. Docker 25 and later print the full transport error chain, including the underlying dial error, which makes the failing layer visible; older versions truncated it at Client.Timeout.
Never underestimate the registry host. registry-1.docker.io resolves to a set of addresses that changes by region, and a firewall allow-list pinned to one IP will fail intermittently. Test with a host allow-list, not an IP list, and compare results from a container and the host to locate the boundary.
Confirming from inside the network. The CIDR calculator settles whether the registry or proxy address is inside a routed range before you spend time on firewall rules, and a request against the registry with the curl builder reproduces the exact headers and timing the daemon would use — including whether NO_PROXY was honoured.
Reference material: Docker daemon proxy configuration and Docker networking overview.
Official references
primary documentationThe Docker documentation that defines the behaviour this guide explains.
Try matching browser tools
All toolsSmall utilities that fit Docker work — they run entirely in this browser tab, so nothing you paste leaves your device.
Related Docker guides
All Docker guidesDocker build: failed to compute cache key: not found
BuildKit cannot hash a file that is not in the context. Correct the context path, the .dockerignore rules, or the COPY source and stage name.
Docker: Cannot connect to the Docker daemon at unix:///var/run/docker.sock
An endpoint mismatch, a stopped daemon, or a missing socket mount. Resolve which of the three, then start, retarget, or mount.
Docker: Ports are not available: exposing port TCP address already in use
The daemon could not bind the host port. Find the listener, change the host side of the mapping and stop stale containers or proxies.
Docker Hub: toomanyrequests and the pull rate limit behind it
Shared CI addresses drain the anonymous quota. Log in, cache the bytes once, and stop pulling production images from Docker Hub.
More in Docker
All Docker guidesThe guides filed next to this one in Docker, in library order.