Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
CURL timeout error handling (Connection/Operation timed out)

CURL timeout error handling (Connection/Operation timed out)

CURL parameter --max-time includes --connect-timeout to separate the timeout of the handshake phase.

CURL - Timeouts · Everything curl

In addition, CURL can distinguish timeout errors at different stages: "connection timeout" and "operation timeout".

For example, CURL command with 5 second connection timeout and 25 second maximum timeout setting:

$ curl -v --connect-timeout 5 -m 25 ""

Example of Error

Connection timeout

curl: (28) Connection timed out after 5004 milliseconds

Operation timeout:

curl: (28) Operation timed out after 25005 milliseconds with 0 bytes received

Error Handling

Both timeout error codes are "28" and cannot be identified by code, but can be identified by message.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment