LightAtom

curl -v: Debug HTTP Requests Step by Step

curl -v shows every step of a request: name lookup, connection, TLS handshake, request and response headers. Add -w to time each phase.

curl -v -o /dev/null https://example.com

Show the full conversation, discard the body.

intermediate10 minNeeds: Terminal (curl is built in)

When to use it

Use curl -v when a request fails or behaves oddly: wrong redirect, TLS error, unexpected status code, missing header. It's also the quickest way to see which IP and protocol a client really used.

Steps

  1. Run a verbose request

    -v prints the conversation to stderr; -o /dev/null throws away the body so it doesn't flood the terminal.
    curl -v -o /dev/null https://example.com
  2. See only the headers

    -I sends a HEAD request and prints response headers. Some servers answer HEAD differently; use -sD - -o /dev/null for a GET's headers.
    curl -sD - -o /dev/null https://example.com
  3. Time each phase

    -w prints timing variables after the request: DNS, TCP connect, TLS, first byte and total.
    curl -s -o /dev/null -w '%{time_namelookup} %{time_connect} %{time_appconnect} %{time_starttransfer} %{time_total}\n' https://example.com
  4. Go deeper

    --trace-ascii writes every byte sent and received to a file.
    curl --trace-ascii trace.txt https://example.com

Output explained

Real curl -v output from macOS 15 (shortened):

* Host example.com:443 was resolved.
* IPv6: 2606:4700:10::ac42:93f3, 2606:4700:10::6814:179a
* IPv4: 172.66.147.243, 104.20.23.154
*   Trying [2606:4700:10::ac42:93f3]:443...
* Connected to example.com (2606:4700:10::ac42:93f3) port 443
* ALPN: curl offers h2,http/1.1
* SSL connection using TLSv1.3 / AEAD-CHACHA20-POLY1305-SHA256
* ALPN: server accepted h2
* Server certificate:
*  subject: CN=example.com
*  issuer: C=US; O=SSL Corporation; CN=Cloudflare TLS Issuing ECC CA 3
> GET / HTTP/2
> Host: example.com
> User-Agent: curl/8.7.1
< HTTP/2 200
< content-type: text/html
  • Lines with * are curl's notes: resolution, the address it tried, TLS details and certificate.
  • > lines are the request headers curl sent; < lines the response.
  • ALPN shows the negotiated protocol (here HTTP/2).
  • curl tried IPv6 first because the name has AAAA records and the Mac has IPv6.

The timing line dns:0.0023 connect:0.0713 tls:0.1454 ttfb:0.2129 total:0.2131 is cumulative: DNS took 2 ms, TCP connect ~69 ms more, TLS ~74 ms more, and the server took ~67 ms after that to send the first byte.

Options and variations

FlagMeaningExample
-vVerbose: connection, TLS and headerscurl -v https://example.com
-IHEAD request, show response headerscurl -I https://example.com
-LFollow redirectscurl -vL http://example.com
-w FORMATPrint variables after the transfercurl -w '%{http_code}\n' -o /dev/null -s URL
--resolve HOST:PORT:IPForce an address, bypassing DNScurl --resolve example.com:443:203.0.113.10 https://example.com
-4 / -6Use only IPv4 / IPv6curl -4 -v https://example.com
--http1.1 / --http2Force an HTTP versioncurl --http1.1 -v https://example.com

Common errors

ErrorCauseFix
curl: (6) Could not resolve hostDNS failedCheck the name, DNS and proxy variables.
curl: (7) Failed to connect … Connection refusedNothing listening on that portCheck the port and that the server runs.
curl: (60) SSL certificate problemCertificate not trustedSee the “unable to get local issuer certificate” guide; don't use -k in production.
curl: (28) Operation timed outNo response in timeCheck reachability with nc -vz host port; raise --max-time if the server is just slow.

Do it in the app

LightAtom's connections view shows curl's connection to the server, which address family it used and how many bytes moved.

Frequently asked questions

What does curl -v do?

It prints details of the whole transfer: name resolution, the address it connects to, the TLS handshake and certificate, and every request and response header.

How do I measure response time with curl?

Use -w with timing variables: time_namelookup, time_connect, time_appconnect (TLS), time_starttransfer (first byte) and time_total. Each is seconds since the start.

Why does curl -v print to the terminal even with -o?

Verbose output goes to stderr, while -o only redirects the body. Redirect stderr with 2>file to save the verbose output.

LightAtom team

The people who build LightAtom, a network monitor for macOS.