Client.Timeout exceeded while awaiting headers Go Origin: Application & API OSI layer 7 · Application Last updated 4 Nov 2026

Go: net/http: request canceled (Client.Timeout exceeded while awaiting headers)

An http.Client with a Timeout gave up waiting for the server's response headers.

Exact message you may see net/http: request canceled (Client.Timeout exceeded while awaiting headers)Client.Timeout exceeded while awaiting headersnet/http: request canceled while waiting for connection (Client.Timeout exceeded while awaiting headers)net/http: TLS handshake timeoutClient.Timeout or context cancellation while reading body
Seen on: Go

Meaning

The server was slow or hung, or the client Timeout is too short. http.Client.Timeout covers the whole exchange including body read. Use Transport settings (ResponseHeaderTimeout, DialContext) for finer control and never use the default client without a timeout in production.

Common causes

  • Slow upstream API
  • Timeout too short
  • Network partition or DNS slowness
  • Large response body reading time included
  • Overloaded server behind a proxy

⚡ Quick fix

  1. Raise Client.Timeout or tune ResponseHeaderTimeout
  2. Retry idempotent requests with backoff
  3. Add observability for upstream latency

Detailed fix by platform

Go

  1. client := &http.Client{Timeout: 15 * time.Second}

How to diagnose

  1. Phase — Dial, headers or body?
  2. Value — Reasonable?
  3. Upstream — Slow?

🔧 Still not fixed?

Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:

Where this error sits

Origin: Application & API. Errors that are often confused with or caused by this one (click to open):

assignment mismatch: 1 variable but f returns 2 values — Go: assignment mismatch: 1 variable but os.Open returns 2 values (Go)assignment mismatch: …context deadline exceeded — Go: Get "https://api.example.com": context deadline exceeded (Client.Timeout exceeded while awaiting headers) (Go)context deadline exce…dial tcp: connect: connection refused — Go: dial tcp 127.0.0.1:5432: connect: connection refused (Go)dial tcp: connect: co…http: superfluous response.WriteHeader call — Go: http: superfluous response.WriteHeader call from main.handler (main.go:25) (Go)http: superfluous res…listen tcp :8080: bind: address already in use — Go: listen tcp :8080: bind: address already in use (Go)listen tcp :8080: bin…panic: assignment to entry in nil map — Go: panic: assignment to entry in nil map (Go)panic: assignment to …too many open files — Go: accept tcp [::]:8080: accept4: too many open files / open x: too many open files (Go)too many open filesClient.Ti…

Explore the map of this error Full error map →

🧠 Still stuck? Analyze your error

Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.

💬 What worked for others

No tips yet — did something else fix this for you?

Share what worked for you

Tips are checked by an editor before they appear. Links are removed.