How to Enable Verbose Output in Curl
When troubleshooting network requests or API connections, seeing the
exact raw data sent and received is crucial. This article explains how
to enable verbose debugging output in a curl command using
various command-line flags. You will learn how to inspect request and
response headers, view SSL/TLS handshakes, and export detailed debug
logs to a file for analysis.
The Basic Verbose Flag
(-v or --verbose)
The easiest way to enable debugging in curl is by adding
the -v or --verbose flag. This option
configures curl to write informational data to the standard
error stream (stderr), including the IP address connected to, the TLS
handshake, sent/received headers, and protocol details.
To use it, append -v to your command:
curl -v https://api.example.com/dataUnderstanding the Output Symbols
When reading the verbose output, pay attention to the prefix symbols:
* * represents internal curl information
(connection status, TLS handshakes, certificates). * >
represents headers sent by curl to the server. *
< represents headers received from the server.
Detailed Trace
Logging (--trace and --trace-ascii)
If the standard verbose mode does not provide enough detail, you can use the trace options. These options log everything, including all incoming and outgoing data, to a specified file.
Complete Hex Dump with
--trace
The --trace option outputs a full hex dump of all
transmitted data. It requires a file path to save the log.
curl --trace debug_hex.txt https://api.example.com/dataReadable Text with
--trace-ascii
If you do not want hex formatting and prefer a highly detailed,
readable text-only log of the transfer, use
--trace-ascii:
curl --trace-ascii debug_ascii.txt https://api.example.com/dataViewing Only Headers
(-i and -I)
If you want to debug the transaction without seeing SSL negotiation details or sending full data dumps, you can inspect the HTTP headers directly.
Include Headers in Output
(-i)
The -i or --include flag displays the
response headers along with the response body:
curl -i https://api.example.com/dataFetch Headers Only (-I)
If you only care about the headers and want to perform a
HEAD request (which does not download the response body),
use the -I or --head flag:
curl -I https://api.example.com/dataSaving Verbose Output to a File
Because curl sends its verbose diagnostic information to
the standard error stream (stderr) and the actual response body to
standard output (stdout), a standard redirection (>)
will only capture the response body.
To redirect the verbose debugging output to a text file for further
analysis, redirect stderr (2>) to a file:
curl -v https://api.example.com/data 2> curl_debug.txt