curl: (28) Operation timed out

Fix curl error 28 when DNS resolution or TCP connection exceeds the configured timeout.

curl: (28) Operation timed out

curl produces error 28 when DNS resolution or TCP connection exceeds the configured timeout.

When curl Produces This Error

curl displays "Operation timed out after {ms} milliseconds" when it cannot complete the request within the timeout window. The default timeout for curl is no limit — this error appears when --connect-timeout or --max-time is set, or when the system's TCP timeout is reached.

What Causes Timeout Error 28 in curl

DNS resolution fails or takes too long. The server is unreachable (wrong IP, network partition, firewall dropping packets silently). The server is overloaded and does not respond to the TCP SYN within the timeout window.

How to Fix Timeout Error 28 in curl

  1. Test DNS resolution separately:

    dig example.com
  2. Test TCP connectivity:

    nc -zv example.com 443 -w 5
  3. Increase the timeout:

    curl --connect-timeout 30 --max-time 120 https://example.com

How to Verify the Fix

A successful request completes within the timeout and returns the response body.