Skip to content

Instantly share code, notes, and snippets.

@yidas
Last active April 24, 2024 09:57
Show Gist options
  • Save yidas/467968d25cd7424cb5ea98500300680f to your computer and use it in GitHub Desktop.
Save yidas/467968d25cd7424cb5ea98500300680f to your computer and use it in GitHub Desktop.
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 "https://yourname.com"

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