V-Spark Online Help

Tips for Debugging and Managing cURL Calls

If you are having problems troubleshooting a curl command, you can obtain verbose debugging information by appending the --trace-ascii FILENAME to your cURL command. This will save a record of every interaction between the cURL command and the host that you are trying to contact into the file FILENAME. Examining the content of this file can often help you identify the cause of a problem.

The cURL command does not have a built-in timeout. Waiting for a cURL command to return can be irritating because it depends on network congestion and the responsiveness of the host on which cURL is running, both of which are often out of your control.

To specify a timeout for the entire span of your cURL command, you can add cURL's --max-time SECONDS option to your cURL commands. This option terminates you cURL command if it exceeds the number of seconds that you specified as an argument. The cURL command also provides options (--speed-limit and --speed-time that enable you to set requirements for transfer speed and which provide other ways to automatically terminate poorly-performing cURL commands.

The cURL command also provides options that enable you to retrieve the status of a cURL call. You can use a cURL call like the following to retrieve the HTTP return code from an API call:

curl -s -LI URL -o /dev/null -w '%{http_code}'

The arguments to this cURL call are the following:


Tells cURL to follow the URL if it is marked as having been moved


Only returns the HTTP header, which is where the HTTP response code is located


Causes cURL to run in silent mode. Ordinarily, cURL displays a progress meter as it executes.


Tells cURL where to write the general output of the command. In this case, /dev/null, the Linux and macOS bit bucket is used. On Windows systems, you can write to a file named nul, for which Windows provides built-in device driver support.


Specifies what cURL should write to standard output, and how to format that information. The string '%{http_code}' simply writes the contents of the variable http_code