Pages

Topics

Tools

↑↓navigate↵openescclose
All guides

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.

~5 min readDocker
#docker#registry#proxy#networking
Bold white headline reading PULL TIMEOUT with a Docker daemon crate reaching a cyan registry gate across a broken network pipe.

Introduction & Quick Summary

A pull never gets an HTTP response back:

code
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 docker

Do 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:

SettingFileApplies to
proxysystemd unit environment or ~/.docker/config.json proxiespulls, builds, pushes
MTU/etc/docker/daemon.json mtucontainer and bridge traffic
DNShost /etc/resolv.conf or daemon.json dnscontainer resolution
registry mirrorsdaemon.json registry-mirrorspull routing
insecure registriesdaemon.json insecure-registriesplain-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=0

Docker 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 fragmentLayerFirst check
Client.Timeout exceeded while awaiting headersdial or TLS handshakeproxy, MTU, firewall
TLS handshake timeoutTLS handshakeTLS-inspecting proxy, clock
dial tcp: i/o timeoutTCP connectroute, MTU, security group
no such hostDNSresolver, search domains, VPN
connection reset by peermiddleboxMTU black hole, IDS
toomanyrequests / 429registry rate limitpull limits, mirror, auth
x509: certificate signed by unknown authoritytrust storecorporate CA in the daemon

Where the setting has to be configured for each environment:

EnvironmentProxy locationRestart needed
Linux + systemdsystemctl edit docker drop-inyes
Docker DesktopSettings, Resources, Proxiesyes
rootless Docker~/.config/systemd/user/docker.service.dsystemctl --user
GitLab or GitHub runnercontainer env on the jobno, if set before start
Podman~/.config/containers/containers.confno

MTU by link type, since this is the least obvious cause:

LinkTypical MTUSymptom
Ethernet1500none
PPPoE1492pulls hang after the first packet
WireGuard / OpenVPN1420 / 1400TLS handshake stalls
IPsec / GRE1400 or lesssmall requests work, large blobs stall
Cloud overlay (VXLAN)1450intermittent 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 -1

If 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

ini
# /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 nameservers

On 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:

bash
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

bash
docker pull alpine:3.21 # toomanyrequests: You have reached your pull rate limit. # versus # net/http: request canceled ... Client.Timeout exceeded

A 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 documentation

The Docker documentation that defines the behaviour this guide explains.

Try matching browser tools

All tools

Small utilities that fit Docker work — they run entirely in this browser tab, so nothing you paste leaves your device.

All Docker guides

More in Docker

All Docker guides

The guides filed next to this one in Docker, in library order.