Troubleshooting ConnectTimeout errors with the Planet Python SDK

Summary

A httpx.ConnectTimeout means the TCP connection to the server wasn't established within the connect timeout. The SDK's default is 10 s. The request never reached the Planet API, so this is not an application error. The usual causes are on the network path or the client side. They are rarely an API problem.

Typical error:
httpx.ConnectTimeout (TCP connect to api.planet.com:443, connect timeout 10 s)
 

How to tell the error types apart

ErrorMeaningLikely cause
ConnectTimeoutTCP handshake not completedNetwork path, NAT or firewall limits, DNS, client overload, rarely an edge issue
ReadTimeoutConnected, but no response in timeSlow API response or large payload
PoolTimeoutNo free connection in the client poolToo much concurrency for the pool size
HTTP 429Rate limited by the APIToo many requests per second. It is a normal response, not a timeout.
HTTP 5xxServer-side errorReport to Planet Support

Rate limiting at the API level shows up as HTTP 429, not as a connect timeout. Network-level throttling, such as a firewall or WAF dropping connections, can look like a connect timeout.

Common causes

  1. NAT or SNAT exhaustion. Containers, cloud VMs, and office networks usually reach the internet through one or more NAT devices. Each outbound connection uses a source port on the NAT's public IP. If the NAT's session table or port pool fills up, new connections are dropped or delayed. This is common with many concurrent jobs or a shared egress IP. Checking only the host's conntrack table is not enough when there is a second NAT, such as an office router or cloud NAT gateway.
  2. Local port or file descriptor exhaustion. Many short-lived connections can use up ephemeral ports or the open-file limit (ulimit -n).
  3. Slow or failing DNS. In httpx, name resolution happens inside the connect phase, so a slow resolver can show up as ConnectTimeout.
  4. Event loop starvation. Thousands of concurrent tasks in one Python process can delay connection handling.
  5. Firewall, proxy, VPN, or ISP issues. Packet loss, SYN filtering, or a congested uplink.
  6. Platform-side events. An incident or edge or load balancer problem. Check the Planet status page, and contact Support to have logs checked.


A useful clue is failures at nearly the same moment across different hosts, such as api.planet.com and link.planet.com, or across separate processes. That points to a shared cause, such as the uplink, NAT, or DNS, and not to a single script.
 

Diagnostic steps

  1. Record exact timestamps (UTC), the target host, and the SDK, Python, and httpx versions. Check whether failures cluster in time.
  2. Check the Planet status page for incidents in that window.
  3. Reproduce from the same host:
    curl -v --connect-timeout 10 https://api.planet.com
    mtr -rw api.planet.com
  4. Test DNS. Time the lookup (dig api.planet.com) and compare with a fixed resolver such as 1.1.1.1.
  5. Capture traffic during a run:
    tcpdump -i any -nn 'tcp port 443 and host api.planet.com'
    • SYNs go out but no SYN-ACK returns: the problem is in transit or at the NAT.
    • SYNs never leave the host: the problem is local.
  6. Check every NAT hop, including the Docker host, office router or firewall, and cloud NAT gateway. Look at session counts, drops, and CPU. On Linux:
    conntrack -C
    cat /proc/sys/net/netfilter/nf_conntrack_max
  7. Check local limits: ulimit -n and ss -s.
  8. Run the same job from a different network, such as a cloud VM, and compare failure rates.

Mitigations

  • Limit concurrency. The SDK already caps requests at 10 per second and 50 concurrent HTTP requests. Having thousands of orders in flight at once can still stress the client. Use a semaphore or a work queue to limit how many orders are active.
  • Reuse one planet.Session for all orders in a job. Don't create one per request.
  • Retry ConnectTimeout in your own code, with exponential backoff and jitter. The connection never opened, so the request was never sent. That makes a retry safe, even for the POST that creates an order. The SDK retries some errors itself (connection errors, read timeouts, HTTP 429 and 502), but not ConnectTimeout, so retry it in your own code.
  • Handle interrupted downloads separately. If the connection closes mid-download, retry the whole download or resume it. Don't treat it as a connect problem.
  • Spread the load across more egress IPs or NAT gateways, or increase NAT capacity.
  • Raise the connect timeout (optional). The SDK's session fixes the connect timeout at 10 s, and only the read timeout is configurable. The SDK has no option to change it. Overriding the underlying httpx client's timeout relies on private attributes and may break between SDK versions. Raising the timeout hides the symptom but doesn't fix the cause. Prefer the other mitigations.

When to contact Planet Support

Open a ticket if the errors continue after the checks above, or if you see failures across multiple unrelated networks. Please include:
  • Exact UTC timestamps of each failure
  • Your public egress IP(s)
  • Target hostnames (for example, api.planet.com or link.planet.com)
  • SDK, Python, and httpx versions, and the full traceback
  • Concurrency level and job size
  • Results of curl, mtr, and DNS tests
  • Whether other error types (such as 5xx) occurred in the same period

Support can then check edge, load balancer, and WAF logs for your IP at those times.
Was this article helpful?
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.