Example

cURL Timeout Examples

Set cURL request timeouts with --max-time, --connect-timeout, and generated code equivalents for API calls that should fail predictably instead of hanging.

Try Timeout Conversion

Full request timeout

--max-time limits the entire operation, including connection, redirects, request upload, and response download. Use it when a user-facing workflow needs a hard upper bound.

Connection timeout

--connect-timeout only limits the time spent establishing the connection. It is useful when DNS, TCP, TLS, or proxy setup is unreliable.

Generated code behavior

The converter keeps timeout settings in JSON output and maps them into supported target languages where a direct timeout option exists.

cURL timeout input

curl --connect-timeout 3 --max-time 15 -H 'Accept: application/json' https://api.example.com/slow-report

FAQ

What is the difference between --max-time and --connect-timeout?

--connect-timeout covers only connection setup, while --max-time covers the whole cURL operation.

Should every API request have a timeout?

Most production API clients should define timeouts so slow or unreachable services do not block workers indefinitely.