Debug Requests with Curl

Debug Requests with Curl

Debugging HTTP requests is an essential skill for any developer or system administrator. It allows you to inspect the details of your requests and responses, troubleshoot issues, and optimize performance. While there are many tools available for debugging HTTP traffic, Curl is one of the most widely used command line tools. This tutorial explains how to debug requests with a Curl.

Verbose output

The -v or --verbose option enables verbose output. It prints detailed information about the request and the response. Lines prefixed with > represent data sent to the server, lines with < indicate data received from the server, and lines starting with * provide miscellaneous information such as connection details, SSL handshake specifics, and protocol information.

curl -v
curl --verbose

Output example:

*   Trying
* Connected to ( port 443 (#0)
* ALPN, offering h2
< HTTP/2 200 
< date: Mon, 06 May 2024 14:43:21 GMT
< content-type: application/json
< content-length: 256
< server: gunicorn/19.9.0
< access-control-allow-origin: *
< access-control-allow-credentials: true
  "args": {}, 
  "headers": {
    "Accept": "*/*", 
    "Host": "", 
    "User-Agent": "curl/7.81.0", 
    "X-Amzn-Trace-Id": "Root=1-6416c45e-47a4828a557d5fca764271d6"
  "origin": "XXX.XXX.XXX.XXX",
  "url": ""
* TLSv1.2 (IN), TLS header, Supplemental data (23):
* Connection #0 to host left intact

Trace output

The --trace option enables a comprehensive trace dump feature, showcasing all incoming and outgoing data. This trace dump provides a hex dump view of all transmitted and received bytes.

curl --trace -


The --trace-time option adds a high-resolution timer to the beginning of verbose/trace outputs whenever a line is printed. This option can be used with -v/--verbose option and the --trace option.

curl -v --trace-time
curl --trace - --trace-time

Leave a Comment

Cancel reply

Your email address will not be published.