How to get cURL Command to run in verbose mode?


At times when you do not get an error, or do not see the specific information that you are looking for using the cURL command, you can run it in verbose mode.

There are two ways you can run a cURL command in verbose mode.

  1. -v : short hand option.
  2. --verbose : long hand option.
Example:
curl -v http://code2care.org
*   Trying 172.67.164.66:80...
* Connected to code2care.org (172.67.164.66) port 80 (#0)
> GET / HTTP/1.1
> Host: code2care.org
> User-Agent: curl/7.85.0
> Accept: */*
> 
* Mark bundle as not supporting multiuse
< HTTP/1.1 301 Moved Permanently
< Date: Wed, 30 Nov 2022 06:28:18 GMT
< Transfer-Encoding: chunked
< Connection: keep-alive
< Cache-Control: max-age=3600
< Expires: Wed, 30 Nov 2022 07:28:18 GMT
< Location: https://code2care.org/
< Report-To: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?s=t
yhXfH5HzZ2lNGOwsNHd"}],"group":"cf-nel","max_age":604800}
< NEL: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
< Server: cloudflare
< CF-RAY: 772185adfe4a85b9-BOM
< alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400
< 
* Connection #0 to host code2care.org left intact

As you can see, using the -v option or flag, you get more information about the IP address and the Port you are trying to connect to, and using the HTTP 1.1 version. The default User-Agent used here for the GET request is the curl version 7.85.0 and Accept is */*.

In verbose details you can see that the URL has been redirected to a secure HTTPS URL with a 301 redirection.

Example 2:
% curl --verbose https://code2care.org

*   Trying 104.21.91.10:443...
* Connected to code2care.org (104.21.91.10) port 443 (#0)
* ALPN: offers h2
* ALPN: offers http/1.1
*  CAfile: /etc/ssl/cert.pem
*  CApath: none
* (304) (OUT), TLS handshake, Client hello (1):
* (304) (IN), TLS handshake, Server hello (2):
* (304) (IN), TLS handshake, Unknown (8):
* (304) (IN), TLS handshake, Certificate (11):
* (304) (IN), TLS handshake, CERT verify (15):
* (304) (IN), TLS handshake, Finished (20):
* (304) (OUT), TLS handshake, Finished (20):
* SSL connection using TLSv1.3 / AEAD-CHACHA20-POLY1305-SHA256
* ALPN: server accepted h2
* Server certificate:
*  subject: C=US; ST=California; L=San Francisco; O=Cloudflare, Inc.; CN=sni.cloudflaressl.com
*  start date: Jun 10 00:00:00 2022 GMT
*  expire date: Jun 10 23:59:59 2023 GMT
*  subjectAltName: host "code2care.org" matched cert's "code2care.org"
*  issuer: C=US; O=Cloudflare, Inc.; CN=Cloudflare Inc ECC CA-3
*  SSL certificate verify ok.
* Using HTTP2, server supports multiplexing
* Copying HTTP/2 data in stream buffer to connection buffer after upgrade: len=0
* h2h3 [:method: GET]
* h2h3 [:path: /]
* h2h3 [:scheme: https]
* h2h3 [:authority: code2care.org]
* h2h3 [user-agent: curl/7.85.0]
* h2h3 [accept: */*]
* Using Stream ID: 1 (easy handle 0x141013400)
> GET / HTTP/2
> Host: code2care.org
> user-agent: curl/7.85.0
> accept: */*
> 
* Connection state changed (MAX_CONCURRENT_STREAMS == 256)!
< HTTP/2 200 
< date: Wed, 30 Nov 2022 06:47:03 GMT
< content-type: text/html; charset=UTF-8
< cache-control: private, max-age=0, must-revalidate, no-cache, no-store
< content-security-policy: upgrade-insecure-requests;
< display: pub_site_sol
< expires: Tue, 29 Nov 2022 06:47:02 GMT
< pagespeed: off
< response: 200
< set-cookie: ezoadgid_395744=-1; Path=/; Domain=code2care.org; Expires=Wed, 30 Nov 2022 07:17:02 UTC
< set-cookie: ezoref_395744=; Path=/; Domain=code2care.org; Expires=Wed, 30 Nov 2022 08:47:02 UTC
< set-cookie: ezosuibasgeneris-1=75d082ee-ab6e-432a-669a-3b71899c0c9a; Path=/; Domain=code2care.org; Expires=Thu, 30 Nov 2023 06:47:02 UTC; Secure; SameSite=None
...
< set-cookie: lp_395744=https://code2care.org/; Path=/; Domain=code2care.org; Expires=Wed, 30 Nov 2022 07:17:02 UTC
< set-cookie: ezovuuidtime_395744=1669790822; Path=/; Domain=code2care.org; Expires=Fri, 02 Dec 2022 06:47:02 UTC
< set-cookie: ezovuuid_395744=141c0559-522d-4421-5784-29b4ef97d07e; Path=/; Domain=code2care.org; Expires=Wed, 30 Nov 2022 07:17:02 UTC
< vary: Accept-Encoding
< x-content-type-options: nosniff
< x-ez-proxy-out: true 2.3
< x-ezoic-cdn: Bypass
< x-frame-options: SAMEORIGIN
< x-middleton-display: pub_site_sol
< x-middleton-response: 200
< x-origin-cache-control: 
< x-sol: pub_site
< x-sucuri-cache: HIT
< x-sucuri-id: 15037
< x-xss-protection: 1; mode=block
< cf-cache-status: DYNAMIC
< report-to: {"endpoints":[{"url":"https:\/\/a.nel.cloudflare.com\/report\/v3?
s=..%2BUBT%2B7P%%2BS%2FSElLkW%2F"}],"group":"cf-nel","max_age":604800}
< nel: {"success_fraction":0,"report_to":"cf-nel","max_age":604800}
< server: cloudflare
< cf-ray: 7721a1201895f2aa-BOM
< alt-svc: h3=":443"; ma=86400, h3-29=":443"; ma=86400
< 
<!DOCTYPE HTML>....<HTML>
* Connection #0 to host code2care.org left intact

In the above example, we tried to connect to the HTTPS version of the homepage, and you now see a whole, not of more information which includes connecting to the 443 port and the details about the TLS 1.3 certificate and CA Cert details and the TLS handshake details and HTTP/2 GET response with status 200 and a list of Response headers and cookie details.

After all the details you get the HTML payload which I have trimmed to make it more readable.

cURL Command Verbose Mode Example

Facing issues? Have Questions? Post them here! I am happy to answer!

Author Info:

Rakesh (He/Him) has over 14+ years of experience in Web and Application development. He is the author of insightful How-To articles for Code2care.

Follow him on: X

You can also reach out to him via e-mail: rakesh@code2care.org



















Copyright © Code2care 2024 | Privacy Policy | About Us | Contact Us | Sitemap